L2. LAB 2: IPHONE APP DEBUGGING 47
button = UIButton(frame: CGRect(x: 10, y: 50,
width: 300, height: 30))
button.setTitle("Button", for: .normal)
button.addTarget(self, action: #selector(self.buttonClicked),
for: .touchUpInside)
button.backgroundColor = .black
self.view.addSubview(button)
Attach a function to the buttonPress function by adding the following function defi-
nition below the viewDidLoad function:
@objc func buttonPress() {
}
e C code can be done similar to Section 3.4. When a prompt is raised to add a bridging
header to the project, select Yes.”
After the C coding, the Algorithm.h file can be included in the bridging header file. is
allows C functions to be called in the Swift program.
Update the buttonPress function by adding the following line of code to its function
definition:
label.text = String(cString: HelloWorld())
e program can then be built and run similar to the previously created example. On
clicking the button on the GUI, the text changes to Hello UTD!” and the Method Called
is displayed in the Debug Console in Xcode.
More information about the Swift programming language are available at https://sw
ift.org and the documentation for its uses in iPhone and MacOS are available at https:
//developer.apple.com/documentation/swift.
L2 LAB 2:
IPHONE 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.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.218.168.16