Skip to Content
Beginning iOS 5 Application Development
book

Beginning iOS 5 Application Development

by Wei-Meng Lee
January 2012
Beginner content levelBeginner
655 pages
16h 35m
English
Wrox
Content preview from Beginning iOS 5 Application Development

CHAPTER 3 EXERCISE SOLUTIONS

Answer to Question 1

In the .h file:

#import <UIKit/UIKit.h>

@interface OutletsAndActionsViewController : UlViewController
{
    //---declaring the outlet---
    IBOutlet UITextField *txtName;
}

//---expose the outlet as a property---
@property (nonatomic, retain) UITextField *txtName;

@end

In the .m file:

#import “OutletsAndActionsViewController.h”

@implementation OutletsAndActionsViewController

//---synthesize the property---
@synthesize txtName;

- (void)dealloc {
    //---release the outlet---
    [txtName release];
    [super dealloc];
}

Answer to Question 2

In the .h file:

#import <UIKit/UIKit.h>

@interface OutletsAndActionsViewController : UIViewController
{
    //---declaring the outlet---
    IBOutlet UITextField *txtName;
}

//---expose the outlet as a property---
@property (nonatomic, retain) UITextField *txtName;

//---declaring the action---
-(IBAction) btnClicked:(id) sender;

@end

In the .m file:

@implementation OutletsAndActionsViewController

-(IBAction) btnClicked:(id) sender {
     //---action implementation here---
}

Answer to Question 3

Use the alert view when you simply want to notify the user when something happens. Use an action sheet when the user needs to make a selection, usually from a set of options.

Answer to Question 4

//---create a Button view---
frame = CGRectMake(10, 70, 300, 50);
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
button.frame = frame;
[button setTitle:@“Click Me, Please!” forState:UIControlStateNormal];
button.backgroundColor ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering iOS 12 Programming - Third Edition

Mastering iOS 12 Programming - Third Edition

Donny Wals
What Successful Project Managers Do

What Successful Project Managers Do

W. Scott Cameron, Jeffrey S. Russell, Edward J. Hoffman, Alexander Laufer

Publisher Resources

ISBN: 9781118144251Purchase book