Debugging using printf() in Xcode Console
March 2nd, 2011 § Leave a Comment
You can use printf() function inside .m file to indicate the app status such as application starts and ends.
In Xcode, select AppDelegate.m file, insert a line inside applicationDidFinishLaunching: method:
- (void)applicationDidFinishLaunching:(UIApplication *)application {
ā¦
}
Add the following:
printf(ā%s\nā, __FUNCTION__);
Note: The __Function__ has two underscores before and after the FUNCTION.
Add the same line to applicationWillTerminate: method
- (void)applicationWillTerminate:(UIApplication *)application {
…
}
You should be able to see the printed output inside Xcode Console when you launch the app
[AppDelegate applicationDidFinishLaunching:]
After you exit the app by pressing the Home button on the iPhone simulator, you will see this printed output
[AppDelegate applicationWillTerminate:]