3.5. EXECUTING C CODES VIA OBJECTIVE-C 43
• Now a C function is created, which is called and executed via Objective C, just by including
the header ﬁle.
3.5 EXECUTING C CODES VIA OBJECTIVE-C
Now that a C code is written, it needs to be linked to the Objective-C app in order to be executed.
• In ViewController.m, just below #import "ViewController.h" , add
• In the buttonPress method, include the following line:
_label.text = [NSString stringWithUTF8String:HelloWorld()];
is code line alters the text of the label in the program.
• Run the program in the simulator.
On pressing the button in the simulator, the following is observed:
1. e text of the label changes.
2. In the Xcode window, “Method Called” gets printed in the Debug Console at the bottom.
is shows that printing can be done from the C function to the debug console in Xcode.
is feature is used for debugging purposes.
L2 LAB 2:
IOS APP DEBUGGING
After getting a familiarity with the Xcode IDE by creating and modifying an iOS app project
and running the app on an iPhone simulator, the following lab experiment can be done to debug
C codes via the built-in Xcode debugger.
To obtain familiarity with the Xcode debugging tool, perform the following:
• Begin by acquiring the C code to be used for this lab.
• Open the folder containing the project.
• Double click on the ﬁle with the extension .xcodeproj.
• Navigate to the C code in the Project Navigator.