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:]

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

What’s this?

You are currently reading Debugging using printf() in Xcode Console at Web Builders.

meta

Follow

Get every new post delivered to your Inbox.