Skip to content

Instantly share code, notes, and snippets.

uint8 *fourchan = (uint8*) malloc(sizeof(uint8) * width * height * 4);
short cur;
short *subscript = (short*) imgData;
for (int i = 0; i < width * height; i++) {
cur = (subscript[i] + 1000) / (int) pow(2., sizeof(short)/2.);
fourchan[i*4] = (uint8) cur;
}
@interface MyClass ()
@property (readwrite, strong) CFMutableSetRef __attribute__((NSObject)) completeContents;
@end
Boolean APIObjectEqual (const void *value1, const void *value2);
Boolean APIObjectEqual (const void *value1, const void *value2)
{
- (NSArray *)chunkifyWithMaxSize:(NSUInteger)size
{
NSArray *r;
NSUInteger c = [self count];
NSUInteger numFullChunks = / size;
NSUInteger lastChunkPosition = size * numFullChunks;
@autoreleasepool
{
NSMutableArray *result = [[NSMutableArray alloc] initWithCapacity:numFullChunks + 1];
for (NSUInteger chunk = 0; chunk < numFullChunks; chunk++)
@interface MyClass : NSObject
@property (readwrite, copy) NSArray *someArray;
@end
@implementation MyClass
{
NSMutableArray *someArrayBacking;
}
// In MyClass.h
@interface MyClass : NSObject
@end
// In MyClass.m
@interface MyClass ()
- (void)a;
- (void)b;
// In the header
@interface MyClass : NSObject
@property (readwrite, assign) int a;
@end
// In a separate header that you include in all MyClass subclasses
@interface MyClass (Protected)
class Foo : public Bar
{
public:
void printFoo(void);
};
void Foo::printFoo(void)
{
cout << "Foo";
}
__block SomeObject *a = [SomeObject someObject];
[a setCompletion:^()
{
[self removeSomeObject:a];
}];
[self addSomeObject:a];
[NSTask launchedTaskWithLaunchPath:@"/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/texturetool"
arguments:[NSArray arrayWithObjects:
@"-e",
@"PVRTC",
@"--channel-weighting-perceptual",
compressionLevel,
@"-f",
@"PVR",
@"-o",
compressedTexturePath,
@implementation MyDocument
- (void)dealWithCompressionFinished:(TextureAtlas *)ta
{
[textureController closeCompressingSheet];
if (nil == [ta previewImage])
{
[[NSAlert alertWithMessageText:@"Invalid Texture"
defaultButton:@"OK"