Irving iOS Jumpstart Meetup - Objective-C Session 2

75 %
25 %
Information about Irving iOS Jumpstart Meetup - Objective-C Session 2
Technology

Published on March 12, 2014

Author: irving-ios-jumpstart

Source: slideshare.net

Description

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.

Objective-C Programming Irving iOS Jumpstart

Objective-C Programming March 11, 2014

Overview of Today • Quick 5 Realms Overview • Objective-C Messaging • Simple Programmatic UITableView Example • Realistic UITableView Example

5 Realms for Learning iOS Development Download full 5 Realms presentation at: http://www.slideshare.net/irving-ios-jumpstart/5-realms

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.

Why 5 Realms? Knowing which realm you're having trouble in really helps in finding the solution and getting unstuck in your learning efforts.

5 Realms Design Patterns Objective-C iOS SDK OOP Xcode IDE

Objective-C Messaging Objective-C

Defining Classes in Objective-C • Created via .h file and .m file • All classes inherit from NSObject or another class Objective-C

@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

@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

Objective-C Methods • Class method + (return_type)methodName • Instance method - (return_type)methodName • Distinguished by + or - Objective-C

Objective-C Methods - (void)addHotels { NSArray *hotels = [NSArray arrayWithObjects:@"Aloft", @"The W", @"Hilton", nil]; ourHotels = [NSArray arrayWithArray:hotels]; } - (return_type)methodName Objective-C

Method With Arguments • this method has one argument - (void)listOurHotelsUsingTitle: (NSString *)title { NSLog(@"%@: %@", title, ourHotels); } Objective-C

Method With Arguments • including sample method call below - (void)listOurHotelsUsingTitle:(NSString *)title { NSLog(@"%@: %@", title, ourHotels); } ! [self listOurHotelsUsingTitle:@"Favorite Hotels"]; Objective-C

Foundation Framework • NSString - the Foundation Framework class used to create string objects! NSString *city = @"Irving"; iOS SDK

Foundation Framework NSString *myStory = [NSString stringWithFormat:@"The brown fox lives in %@", city]; //The brown fox lives in Irving iOS SDK

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

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

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

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

Foundation Framework • NSArray shortcut (objective-c literals)! NSArray *hotels = @[@"Aloft", @"The W", @"Hilton"]; • Cleaner and familiar syntax iOS SDK

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

Foundation Framework - (void)addHotelsWithRatings { NSDictionary *hotels = [NSDictionary dictionaryWithObjectsAndKeys:@"5 star", @"Aloft", @"4 star", @"W", @"5 star", @"Hilton", nil]; ! NSLog(@"%@", hotels); } iOS SDK

Foundation Framework • NSDictionary shortcut (objective-c literals)! NSDictionary *hotels = @{@"Aloft":@"5 star", @"W":@"4 star", @"Hilton":@"5 star"}; • Cleaner syntax iOS SDK

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

Mutable Objects NSString (immutable) NSMutableString (mutable) NSArray NSMutableArray NSDictionary NSMutableDictionary iOS SDK

Mutable Objects • NSMutableString Example NSMutableString *iCanChange = [NSMutableString stringWithString:@"Hello..."]; NSLog(@"%@", [iCanChange stringByAppendingString:@"world!"]); // Hello...world! iOS SDK

Mutable Objects Download samples from github ! https://github.com/jamesderry iOS SDK

Programmatic UITableView Crosses several realms of IOS understanding. ! ! ! Design Patterns Objective-C iOS SDK OOP Xcode IDE

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

Programmatic UITableView • Design Patterns • Model - View - Controller (MVC) pattern • Delegate pattern • Datasource pattern Design Patterns

Programmatic UITableView • Objective-C features • Protocols • Classes (UITableView and UITableViewCell) • Dot syntax for cell properties Objective-C

Programmatic UITableView • iOS SDK Features • UIViewController (and view controller life cycle) • UIView • UITableView and UITableViewCell iOS SDK

Programmatic UITableView Exercise Create simple table view app

Programmatic UITableView Exercise Common Pitfalls • forgetting to match the prototype cell identifier name to the name used in your code • forgetting to set the tableview datasource and delegate

Thank You! • Credits • Wikipedia • Programming in Objective-C by Stephen Kochan (any errors or omissions are probably mine)

Add a comment

Related presentations

Related pages

Irving iOS Jumpstart (Irving, TX) - Meetup

... Objective C and the iOS SDK. ... Session Five. 10 iOS Artists ... Irving iOS Jumpstart http://www.meetup.com/Irving-iOS-Jumpstart/ Irving, TX
Read more

Lessons Learned from Making it to the #1 Spot in the App ...

Find a Meetup Group ... Irving iOS Jumpstart. Home; Members; Sponsors Photos; Pages Discussions; More Polls; Files; Report this group; Join us!
Read more

Irving-iOS-Jumpstart · GitHub

Irving-iOS-Jumpstart. ... A demo of how to create animated video player views in both Objective-C and Swift ... Reload to refresh your session.
Read more

Sessions

Submit Session; Meetup; Jobs; News; About. INFO. About Overview; FAQ; ... 2:45 PM; Sort by : ... Creating iOS Apps with C# using Xamarin.iOS
Read more

Coding Zero To Coding Hero - Jonathan Lott - YouTube

Coding Zero To Coding Hero - Jonathan Lott ... at both Objective-C and Swift examples ... him share his experiences with Irving iOS Jumpstart!
Read more

Sash Zats - Advanced Fun with Objective-C Runtime - YouTube

Slides: http://www.slideshare.net/alexanderza... Presented at the TLV iOS Developer Meetup on 16/11/2014. A two part drama: Part one: talk the ...
Read more

James Derry | LinkedIn

View James Derry’s professional profile on LinkedIn. LinkedIn is the world's largest business network, helping professionals like James Derry discover ...
Read more

meetup - How people build software · GitHub

version 2 of the Meetup Sassquatch framework ... Updated Apr 27, 2016. Objective-C 5 0 meetup-swatches. Cross ... Reload to refresh your session.
Read more