Sunday, February 13, 2011

iPhone dev Stupidity 143: Size of Image Cut from CGContext

UIGraphicsBeginImageContext(scale_rect.size);
[self drawInRect: scale_rect];

UIImage * thumbnail = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

CGContext will always round to ceiling - trying to hold all drawings.

That means: scale_rect.size.width == 320.00000031 will be rounded to 321. If your app care that 1 point, it’ll cause error.

Friday, February 11, 2011

iPhone dev Stupidity 142: Silencing deprecation warnings

from here:
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"

Wednesday, February 02, 2011

iPhone dev Stupidity 141: applicationWillTerminate: in iOS4 & iOS3

From the iPhone Application Programming Guide:
Even if you develop your application using iPhone SDK 4 and later, you must still be prepared for your application to be terminated. If memory becomes constrained, the system might remove applications from memory in order to make more room. If your application is currently suspended, the system removes your application from memory without any notice. However, if your application is currently running in the background, the system does call the applicationWillTerminate:method of the application delegate. Your application cannot request additional background execution time from this method.
So yes, applicationWillTerminate: will generally not be called very often in iOS 4. If you have to save data, you should do so in both applicationWillTerminate: andapplicationDidEnterBackground: