Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
iOS Overview
Search
Chris Schepman
June 14, 2012
200
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
iOS Overview
Chris Schepman
June 14, 2012
Featured
See All Featured
The Curious Case for Waylosing
cassininazir
1
440
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
340
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
310
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
1.6k
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
310
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
1
270
From π to Pie charts
rasagy
0
240
Mind Mapping
helmedeiros
PRO
1
290
Chasing Engaging Ingredients in Design
codingconduct
0
240
Are puppies a ranking factor?
jonoalderson
1
3.7k
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
190
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
Transcript
An iOS Overview or ... “Oh shit. I just got
put an iOS project! Help?” Thursday, June 14, 12
Quick Resources • Stanford CS193p • cs193p.stanford.edu • WWDC Videos
• Apple Docs (In Xcode!) Thursday, June 14, 12
Objective-C • It is weird. • But you know C
right? • err.. How about Javascript? • .. SmallTalk? Thursday, June 14, 12
“Message Passing” wtf? [activityIndicator startAnimating]; //verbosity cell.textLabel.text = [[songList objectAtIndex:indexPath.row]
title]; //this won’t work! not for methods activityIndicator.startAnimating(); //properties are happier though! activityIndicator.color = [UIColor ...]; Thursday, June 14, 12
Blocks! • So good. [UIView animateWithDuration:.5 animations:^{ self.quoteLabel.alpha = 0;
self.quoteWeb.alpha = 0; self.leftQuote.alpha = 0; self.rightQuote.alpha = 0; if (!isBookmarked) { self.bookmarkImage.alpha = 0; } } completion:^(BOOL finished) { //... }]; Thursday, June 14, 12
Manual Memory Management? • Reference Counting • http://www.raywenderlich.com/5677/ beginning-arc-in-ios-5-part-1 •
ARC is good Thursday, June 14, 12
Make it pretty! [UIView animateWithDuration:.5 animations:^{ //any property in here!
}]; //UIViewAnimationOptionCurveEaseInOut //UIViewAnimationOptionCurveLinear Thursday, June 14, 12
DATA • Core Data • Massive • Fast (speed) •
Slow (development) • Not Flexible • Very Good Documentation Thursday, June 14, 12
DATA - Cont’d Thursday, June 14, 12
DATA - Cont’d • NSUserDefaults • Key Value Store •
Fast (development) • Slow (speed) • Not Real Queries • Good Enough? Thursday, June 14, 12
DATA - Cont’d • Write [[NSUserDefaults standardUserDefaults] setObject:self.bookmarks forKey:@"bookmarks"]; [[NSUserDefaults
standardUserDefaults] synchronize]; • Read self.bookmarks = [[[NSUserDefaults standardUserDefaults] objectForKey:@"bookmarks"] mutableCopy]; Thursday, June 14, 12
DATA - Cont’d • Other Options! • FMDB • https://github.com/ccgus/fmdb
• Objective-C sqlite wrapper • Parse • https://parse.com Thursday, June 14, 12
Text Layout • UILabel doesn’t have a lineHeight property •
UIWebView to the rescue? quoteHTML = @"<html><body style=\"background-color: transparent; font-family: Georgia; line-height: 40px; font-size:18pt; text-shadow: 0px 1px #FFF; text-align: center;\">%@</body></html>"; Thursday, June 14, 12
Must Know Libraries • AFNetworking • https://github.com/AFNetworking/ AFNetworking • Blocks!
Thursday, June 14, 12
Must Know L’s - Cont’d //some function calls this! [self
loadTweetInBackground]; - (void)loadTweetInBackground { [tweetSpinner startAnimating]; latestTweet.text = @""; [NSThread detachNewThreadSelector:@selector(loadTweet) toTarget:self withObject:nil]; } - (void)loadTweet { ! NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; [NSThread sleepForTimeInterval:1]; ! NSString *urlString = @"http://api.twitter.com/1/statuses/user_timeline.json? count=1&screen_name=babykettenOR"; ! NSURL *url = [NSURL URLWithString:urlString]; ! NSString *jsonString = [[NSString alloc] initWithContentsOfURL:url encoding:NSUTF8StringEncoding error:nil]; ! if (jsonString != nil) { id jsonValue = [jsonString JSONValue]; self.tweet = [[jsonValue objectAtIndex:0] valueForKey:@"text"]; } else { self.tweet = @"Can't reach the internetz! Sing pretty!"; } ! [self performSelectorOnMainThread:@selector(didFinishLoadingTweet) withObject:nil waitUntilDone:NO]; ! [jsonString release]; ! [pool release]; } - (void)didFinishLoadingTweet { ! [tweetSpinner stopAnimating]; latestTweet.text = tweet; } Thursday, June 14, 12
Must Know L’s - Cont’d NSURL *url = [NSURL URLWithString:@"https://gdata.youtube.com/feeds/api/standardfeeds/top_rated?
alt=json?time=this_week"]; NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:url]; [urlRequest setValue:@"gzip" forHTTPHeaderField:@"Accept-Encoding"]; MBJSONRequest *jsonRequest = [[[MBJSONRequest alloc] init] autorelease]; [jsonRequest performJSONRequest:urlRequest completionHandler:^(id responseJSON, NSError *error) { if (error != nil) { NSLog(@"Error requesting top-rated videos: %@", error); } else { NSArray *videos = [[responseJSON objectForKey:@"feed"] objectForKey:@"entry"]; for (NSDictionary *videoInfo in videos) { NSString *title = [[videoInfo objectForKey:@"title"] objectForKey:@"$t"]; NSString *author = [[[[videoInfo objectForKey:@"author"] objectAtIndex:0] objectForKey:@"name"] objectForKey:@"$t"]; NSLog(@"'%@' by %@", title, author); } } }]; Thursday, June 14, 12
Must Know L’s - Cont’d • JSONKit • https://github.com/johnezang/JSONKit •
faster than binary .plist! • Nineveh.gl (http://nineveh.gl/) • Import super common models • 3D framework worth exploring (young) Thursday, June 14, 12
Must Know L’s - Cont’d • http://iosboilerplate.com/ • MBProgressHUD /
SVProgressHUD • AFNetworking • Built-in browser • Lots more Thursday, June 14, 12
Totally Screwed? • You know the Web! • UIWebView •
Titanium/PhoneGap • Clutch - https://clutch.io/ • Mobile Safari! Thursday, June 14, 12
THE END Good Fucking Luck. <3 @cschep Thursday, June 14,
12