Step 6: Have some fun by adding things programmatically
1. Delete the label we added to the UI as well as all the code we wrote up to this point.
2. Open ViewController.h and add the Following code between the @interface ViewController: UIViewController and @end:
@property (strong, nonatomic)UILabel *label;
Notice how a circle did not appear this time? That's an indication that you did it correctly
3. In ViewController.m add @synthesize label; right beneath @implementation ViewController and add [self setLabel:nil]; in the viewDidUnload function.
4. In the viewDidLoad function add the following lines of code:
//Define where the label will be displayed
self.label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 320, 100)];
//Define the text to be displayed
self.label.text = @"Hello World";
//Center the Text
self.label.textAlignment = UITextAlignmentCenter;
//Programmatically add the label to the view
[self.view addSubview:self.label];
5. Hit run and admire your handiwork, you've completed your first iOS application
Remove these ads by
Signing Up








































Visit Our Store »
Go Pro Today »




But if you want your app in the AppStore, you need to be in the program.
best regards
Martin
Thank you!!