Session 2 of Objective-C for the Irving iOS Jumpstart meetup. This evening we learned about creating UITableView's and programmatically setting the contents of their UITableViewCell's.
3. Overview of Today
• Quick 5 Realms Overview
• Objective-C Messaging
• Simple Programmatic UITableView Example
• Realistic UITableView Example
4. 5 Realms
for Learning iOS Development
Download full 5 Realms presentation at:
http://www.slideshare.net/irving-ios-jumpstart/5-realms
5. Why 5 Realms?
To the beginning iOS developer the formalities of
classes, frameworks, design patterns, and
learning an all new integrated development
environment can be overwhelming.
6. Why 5 Realms?
Knowing which realm you're having trouble in really
helps in finding the solution and getting unstuck in
your learning efforts.
10. @interface
@implementation
• @interface in an objective-c .h file
• @implementation in an objective-c .m file
• serves to separate the interface of a class
from its implementation.
Objective-C
11. @property
@synthesize
• Objective-C properties
• @property directive is used to create
properties on the class.
• Properties are accessed (read and set) via
automagically created setters and getters.
• In Xcode 5, optionally use @synthesize to
give instance variable a custom name
Objective-C
12. Objective-C Methods
• Class method
+ (return_type)methodName
• Instance method
- (return_type)methodName
• Distinguished by + or -
Objective-C
18. Foundation
Framework
• NSString comparison
if ([city isEqualToString:@"Irving"]) {
NSLog(@"The two strings are the
same.");
} else {
NSLog(@"The two strings are
different.");
} //The two strings are the same.
iOS SDK
19. Foundation
Framework
• NSString comparison
if ([city isEqualToString:myStory]) {
NSLog(@"The two strings are the
same.");
} else {
NSLog(@"The two strings are
different.");
} //The two strings are different.
iOS SDK
20. Foundation
Framework
• NSArray - the Foundation Framework class
used to create array objects!
NSArray *hotels = [NSArray
arrayWithObjects:@"Aloft", @"The
W", @"Hilton", nil];
• An array is a set of ordered data items
iOS SDK
21. Foundation
Framework
NSArray *hotels = [NSArray
arrayWithObjects:@"Aloft", @"The
W", @"Hilton", nil];
• array index begins at zero, so an array with
3 elements are indexed 0, 1, and 2
NSLog(@"The hotel at index 1 in
this array is %@", [hotels
objectAtIndex:1]); // The W
iOS SDK
23. Foundation
Framework
• NSDictionary - the Foundation Framework
class used to store key and value pairs!
NSDictionary *hotels =
[NSDictionary
dictionaryWithObjectsAndKeys:@"5
star", @"Aloft", @"4 star", @"W",
@"5 star", @"Hilton", nil];
iOS SDK
26. Foundation
Framework
• Mutable objects are changeable after
creation.
• Immutable objects cannot change once they
are created.
• Therefore additional methods exist on mutable
objects
iOS SDK
31. Programmatic
UITableView
• Xcode
• Storyboard - we'll build the view controller
storyboard containing a tableview
• IBOutlet - we'll use to grab a handle to the
tableview for manipulation in objective-c
code
Xcode
IDE