three20 framework for ios development

27
Three20 framework for iOS development 李致緯 Chih-Wei Lee Google Summer of Code Student 2010 Email: [email protected] Twitter/Facebook/GitHub: @dlackty

Upload: richard-lee

Post on 13-Jul-2015

2.514 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: Three20 framework for iOS development

Three20 framework for iOS development

李致緯 Chih-Wei LeeGoogle Summer of Code Student 2010

Email: [email protected] Twitter/Facebook/GitHub: @dlackty

Page 2: Three20 framework for iOS development

Google Summer of Code 2010

Page 3: Three20 framework for iOS development

Why you should know more about mobile apps?

Page 4: Three20 framework for iOS development

Lots of new startups build their own mobile app first!

Page 5: Three20 framework for iOS development

Web giants also build wonderful mobile apps.

Page 6: Three20 framework for iOS development

Luke WroblewskiSource : http://www.lukew.com/ff/entry.asp?933

1. Mobile is exploding

2. Mobile forces you to focus

3. Mobile extends your capabilities

Mobile first, web second.

Page 7: Three20 framework for iOS development

Connected to Internet

90% apps has data transmission to server

•Push notifications

•Member system

•Data display/browse

•Online ranking

•Search

Page 8: Three20 framework for iOS development

Cocoa touch aren’t optimized as a web client

•No simple mechanism to manipulate online objects

•Need to make lots of caches of online resource

•Some UI components are missing

•Navigation between view controllers are trivial

•There’re event no built-in JSON parsers!

Page 9: Three20 framework for iOS development

Three20

Page 10: Three20 framework for iOS development

Three20

•Originally developed by Joe Hewitt at Facebook

•Used to build official Facebook app

•Similar to many web frameworks

•Now an most popular Objective-C project on GitHub

Page 11: Three20 framework for iOS development

More on http://three20.info/

Page 12: Three20 framework for iOS development

Three20 modules

Page 13: Three20 framework for iOS development

Three20 Core

Three20 Core provides a basic set of tools useful for debugging your applications, dealing with standard data structures, and doing basic text manipulation.

Examples:

•TT_RELEASE_SAFELY(POINTER);

•NSString* TTPathForDocumentsResource(NSString* relativePath);

•(NSDictionary*)queryDictionaryUsingEncoding:(NSStringEncoding)encoding;

•NSArray - (void)perform:(SEL)selector;

•NSData - (NSString*)md5Hash;

Page 14: Three20 framework for iOS development

Three20 Network

Three20 Network mainly provide TTURLRequest, compared to NSURLRequest, it provides more features.

Features

•HTTP methods support (POST/GET/PUT)

•Simple post parameters

•File-based cache

•Automatically parse downloaded data an validate

•Handle cookies

Page 15: Three20 framework for iOS development

Three20 UICommon

Three20 UICommon provides basic UI utilities for construction of higher level UI modules.

Examples:

•float TTOSVersion();

•BOOL TTIsPad();

•BOOL TTIsKeyboardVisible();

•void TTAlert(NSString* message);

•- (UIView*)findFirstResponderInView:(UIView*)topView;

Page 16: Three20 framework for iOS development

Three20 UINavigator

Three20 UINavigator makes iPhone apps like web apps based on URL-mapping mechanism.

The URLs are mapped into Objective-C view controllers, and the parameters are passed to init method.

Features:

•TTBaseNavigator - The main url handler to open urls

•TTURLAction - Action to open url with some option parameters

•TTURLMap - Map URLS to view controllers

Page 17: Three20 framework for iOS development

TTURLMap* map = navigator.URLMap;[map from:@"*" toViewController:[TTWebController class]];[map from:@"tt://catalog" toViewController:[CatalogController class]];[map from:@"tt://photoTest1" toViewController:[PhotoTest1Controller class]];[map from:@"tt://photoTest2" toViewController:[PhotoTest2Controller class]];[map from:@"tt://imageTest1" toViewController:[ImageTest1Controller class]];[map from:@"tt://tableTest" toViewController:[TableTestController class]];

URL-Mapping examples

TTOpenURL(@"tt://launcherTest");

then, you can simply:

LauncherViewTestController *viewController = [[LauncherViewTestController alloc] init];[self.navigationController pushViewController:viewController animated:YES];[viewController release];

Instead of

Page 18: Three20 framework for iOS development

Three20 Style

Three20 Style make developers to style UIs with a main stylesheets, instead of manually set each UIs style.

Also it provides some utilities to cope with UIs and do images manipulations.

Examples:

•- (UIImage*)transformWidth:(CGFloat)width height:(CGFloat)height rotate:(BOOL)rotate;

•- (void)drawInRect:(CGRect)rect radius:(CGFloat)radius;

Page 19: Three20 framework for iOS development

Three20 UI

Three20 UI is the most wonderful part of the framework, includes enhancements of UIKit, new view controllers and new UI components

Page 20: Three20 framework for iOS development

TTImageView examples

Instead of

TTImageView *imageView = [[TTImageView alloc] initWithFrame:frame]; [imageView setUrlPath:@"http://www.foo.com/bar.jpg"];

UIImageView *imageView = [[UIImageView alloc] initWithFrame:frame]; NSURL *url = [NSURL URLWithString:@"http://www.foo.com/bar.jpg"]; NSData *data = [[NSData alloc] initWithContentsOfURL:url]; [imageView setImage:[UIImage imageWithData:data]];

and with additional asynchronous loading, and disk cache

Page 21: Three20 framework for iOS development

TTPhotoViewController

Page 22: Three20 framework for iOS development

TTMessageController

Page 23: Three20 framework for iOS development

TTLauncherView

Page 24: Three20 framework for iOS development

Three20 extensions

Page 25: Three20 framework for iOS development

Three20 Extensions

extCSSStyleThis extension provides support for reading Three20 style sheets from CSS files.

extXMLThree20 XML Extension for parsing XML objects into Objective-C NSObjects.

extJSONThree20 JSON Extension for parsing JSON objects in to Objective-C NSObjects.

Page 26: Three20 framework for iOS development

Check out http://three20.info/

New official website with docs and tutorials

Page 27: Three20 framework for iOS development

Reference

Official website http://three20.info

GitHub http://github.com/facebook/three20

Google Group http://groups.google.com/group/three20/