@class vs. #import

If you see this warning: warning: receiver ‘MyCoolClass’ is a forward class and corresponding @interface may not exist you need to #import the file, but you can do that in your implementation file (.m), and use the @class declaration in your header file. @class does not (usually) remove the need to #import files, it just … Read more

How does an underscore in front of a variable in a cocoa objective-c class work?

If you use the underscore prefix for your ivars (which is nothing more than a common convention, but a useful one), then you need to do 1 extra thing so the auto-generated accessor (for the property) knows which ivar to use. Specifically, in your implementation file, your synthesize should look like this: @synthesize missionName = … Read more

How to get pixel data from a UIImage (Cocoa Touch) or CGImage (Core Graphics)?

FYI, I combined Keremk’s answer with my original outline, cleaned-up the typos, generalized it to return an array of colors and got the whole thing to compile. Here is the result: + (NSArray*)getRGBAsFromImage:(UIImage*)image atX:(int)x andY:(int)y count:(int)count { NSMutableArray *result = [NSMutableArray arrayWithCapacity:count]; // First get the image into your data buffer CGImageRef imageRef = [image … Read more