I am using ARC in my code and I am getting the error
Object 0x781b8e0 of class __NSCFString autoreleased with no pool in place - just leaking - break on objc_autoreleaseNoPool() to debug
The line it breaks on is
return UIApplicationMain(argc, argv, nil, NSStringFromClass([HomePageAppDelegate class]));
Since I am using ARC I cannot put an NSAutoReleasePool
around it like I usually would. What can I use in order to fix this error?
use this on the line where it showing the warning
@autoreleasepool{
}
You use the @autoreleasepool
construct:
@autoreleasepool {
// main code here
}
This creates a NSAutoReleasePool
with the same scope as the brackets, and it can also be used in MRC code as well. It has the advantages of being cleaned up when exceptions occur, and can easily be used to dispatch threads safely.
To read more, visit this article on Transitioning to ARC Release Notes
Create a new test app with ARC enabled. Look at the code in "main.m" to see what Apple recommends.