際際滷

際際滷Share a Scribd company logo
iPhone Developer Basic Program
Day 2 Objective-C 2.0
by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111
Saturday, June 1, 13
Course Outline
1. Introduction & Xcode
2. Objective-C & Frameworks
3. View &ViewController
4. View &ViewController (2)
5. Submit App Store
Course Outline
by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111
Saturday, June 1, 13
www.ibluecode.com/training.html
Day 1 - 5 際際滷
www.slideshare.net/eakkattiya
Additional Course
eakkattiya@gmail.com
086-6732111
twitter.com/eakkattiya
facebook.com/eakapong.kattiya
Resources
by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111
Saturday, June 1, 13
Object-Oriented Programming
Objective-C 2.0
Developing iOS Apps : Language
http://tinyurl.com/o54n8jd
by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111
Saturday, June 1, 13
Objective-C 2.0
by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111
犢犖犖迦犖о牽犢犖犖巌犖÷犖犖朽権犖犖犖項犖犖萎犖犖犢犖迦 ?
- Class & Object ( 犖犖ム顕犖 & 犖犖犖犢犖犢犖 )
- Inheritance 犖犖迦牽犖犖劇犖犖犖犖犖ム顕犖 / Subclass 犖犖ム顕犖犖ム弦犖
- Interface and Implementation
- Method & Property
- Alloc & init
Class & Object
Inheritance &
Subclass Interface &
Implementation
Method &
Property
Instantiation
Saturday, June 1, 13
Objective-C 2.0 : Class vs. Object
by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111
Class = 犢犖犖犢犖犖ム犖犖犖劇賢犖犖巌検犖犢犢犖犖朽権犖/犖犖犖巌犖犖犖犖о険犖犖犖
Object = 犖о険犖犖犖
Class ------ Implement -----> Object
犖犖ム顕犖 (犢犖÷犢犖犖) ------ 犖犢犖迦犖犖犖犢犖迦犢犖犢犖 ---> 犖о険犖犖犖
Saturday, June 1, 13
Objective-C 2.0 : Class vs. Object
by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111
UIView *myView ;
ClassName *objectName ;
Framework
<UIKit>
犖犖謹犖犖犢犖犖犢犖о権犖犖園硯犢犖ム犖犢犖犖÷賢犖犖謹犖犖犢犖犖犢犖о権犖犖園硯犢犖犖犢犢犖犖÷賢
Saturday, June 1, 13
Objective-C 2.0 : Primitive Types (犖犖園硯犢犖犖犢犖犢犖犖犢犖迦犖劇犖犖犖迦)
by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111
BOOL isCorrect = NO ; //YES
NSInteger myInteger = 1234 ;
CGFloat myFloat = 123.40 ;
double myDouble = 123.40 ;
Objective-C 2.0 : Value Object Types (犖犖園硯犢犖犖犢犖犢犖犖犢犖迦犖劇犖犖犖迦 + Method)
NSNumber *number = @1234 ;
NSString *name = @"world" ;
NSString *greeting = [NSString stringWithFormat:@"Hello, %@ , %d",
name,
[number integerValue]];
Saturday, June 1, 13
Objective-C 2.0 : If Else Condition (犢犖犖劇犖犖犢犖)
by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111
NSString *name = @"world" ;
BOOL isCorrect = [name isEqualToString:@"world"]; //Method
if(isCorrect){ //Block
NSLog(@"Welcome %@",name);
}else{
NSLog(@"Wrong user name");
}
Saturday, June 1, 13
Objective-C 2.0 : NSArray (犢犖犢犢犖犖犢犖犖÷弦犖ム犖÷犢犖犢)
by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111
// Compose a static array of string objects
NSString *objs[3] = {@"One", @"Two", @"Three"};
// Create an array object with the static array
NSArray *arrayOne = [NSArray arrayWithObjects:objs count:3];
// Create an array with a nil-terminated list of objects
NSArray *arrayTwo = [NSArray arrayWithObjects:@"One", @"Two", @"Three", nil];
NSArray *arrayThree = @[ @"Hello World", @67, [NSDate date] ];
// get second object in array @67
NSNumber *two = [arrayThree objectAtIndex:1];
Objective-C 2.0 : NSMutableArray (犢犖犢犢犖犖犢犖犖÷弦犖ム犖犢)
NSMutableArray *mutableArray = [NSMutableArray new];
[mutableArray addObject:@"First"];
[mutableArray removeObjectAtIndex:0];
Saturday, June 1, 13
Objective-C 2.0 : NSDictionary (犢犖犢犢犖犖犢犖犖÷弦犖ム犖÷犢犖犢)
by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111
NSDictionary *myDict =
[NSDictionary dictionaryWithObjectsAndKeys:@"eak",@"name",
@10,@"age",
YES,@"isPass",
nil];
NSString *name =[myDict valueForKey:@"name"] ;
Objective-C 2.0 : NSMutableDictionary (犢犖犢犢犖犖犢犖犖÷弦犖ム犖犢)
NSMutableDictionary *myDict =
[NSMutableDictionary dictionaryWithObjectsAndKeys:@"eak",@"name",
@10,@"age",
YES,@"isPass",
nil];
[myDict setValue:@100 forKey:@"score"] ;
NSString *score = [myDict valueForKey:@"score"];
Saturday, June 1, 13
犖犖迦牽犖犖劇犖犖犖犖犖ム顕犖 Inheritance & Subclass
1. 犖犖ム顕犖 犖犖伍犖犖園硯犖犢犖犖犖÷元犖犖迦牽犖犖劇犖犖犖犖犖迦 犖犖ム顕犖犢犖÷ (Super class) 犢犖犢犖
UILabel 犖犖劇犖犖犖犖÷顕犖犖迦 UIView
2. 犖∇犢犖о犖 犖犖ム顕犖 NSObject 犢犖犖劇犖犖犖犖迦犢犖犢犖犖犖ム顕犖犢犖÷犖犖犖犖犖伍犖犖園硯
by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111
Saturday, June 1, 13
Objective-C 2.0 : Interface & Implementation
by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111
Saturday, June 1, 13
Objective-C 2.0 : Interface (.h 鍖le)
by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111
@interface classname : superclassname {
// instance variables
NSString *userInput ;
}
// Class Property
@property (weak, nonatomic) IBOutlet UILabel *myLabel;
@property (weak, nonatomic) NSString *name ;
+ classMethod1;
+ (return_type)classMethod2;
+ (return_type)classMethod3:(param1_type)param1_varName;
- (return_type) instanceMethod1With1Parameter:(param1_type)param1_varName;
- (return_type)instanceMethod2With2Parameters:(param1_type)param1_varName
param2_callName:(param2_type)param2_varName;
@end
Saturday, June 1, 13
Objective-C 2.0 : Implementation (.m 鍖le)
by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111
@implementation classname
+ (return_type)classMethod
{
// implementation
}
- (return_type)instanceMethod
{
// implementation
}
@end
Saturday, June 1, 13
Objective-C 2.0 : Messages (Method)
by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111
@implementation classname
- (void)viewDidLoad
{
[super viewDidLoad];
//Call Method
[self changeColorToRed:5.0 green:2.0 blue:6.0];
}
// Method implementation
- (void)changeColorToRed:(float)red green:(float)green blue:(float)blue{
UIColor *color = [UIColor colorWithRed:red
green:green
blue:blue
alpha:1.0];
[self.view setBackgroundColor:color];
}
Saturday, June 1, 13
Objective-C 2.0 : Instantiation (犖犖迦牽犖犖犢犖迦 Object)
by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111
MyClass *myObject1 = [[MyClass alloc]init];
[myObject1 setName:@"Hello"];
myObject1.name = @"Hello";
MyClass *myObject2 = [MyClass new];
[myObject2 setName:@"Hello"];
MyClass *myObject3 = [[MyClass alloc]initWithString:@"Hello"];
Saturday, June 1, 13
Developing iOS Apps : Frameworks
by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111
Saturday, June 1, 13
Developing iOS Apps : Frameworks
by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111
Saturday, June 1, 13
Developing iOS Apps : Frameworks
by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111
Saturday, June 1, 13
http://www.apple.com/ios/ios6/
Developing iOS Apps : Frameworks
by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111
Saturday, June 1, 13
Developing iOS Apps : Design Patterns
Model-View-Controller
Target-Action
Delegation
Block Objects
Protocol
Noti鍖cation Center
Key-Value Observing (KVO)
http://tinyurl.com/o8pnof9
by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111
Saturday, June 1, 13
Model-View-Controller (MVC)
by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111
Saturday, June 1, 13
Model-View-Controller (MVC)
by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111
Saturday, June 1, 13
by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111
Saturday, June 1, 13
Model-View-Controller (MVC)
Model
犢犖犢犖 Class 犖犖朽犖犖犢犖迦犖犖謹犖犢犖犖劇犖犢犖犢犢犖犢犖犖犢犖犖÷弦犖ム犖犖犢犖犖犢犖犖犖
犢犖犢犖 Class Contacts 犢犖犢犖犖犖迦権犖犖劇犖 犢犖犖犖犢犢犖犖 犖犖項犖犖巌犖犢犖
犢犖犖∇犖÷犖犢犖迦犖犢犖犖犢犖犖犖犢犖迦犖謹犖犖謹View 犢犖ム鍵 Controller
by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111
Saturday, June 1, 13
Model-View-Controller (MVC)
- View
犢犖犢犖 Class 犖犖朽犖犖犢犖迦犖犖謹犖犢犖犖劇犖犢犖犖犖犖犖ム犖犖犖犢犖迦犖 犢犖犢犖 UIView ,
UILabel , UITextField 犢犖犖∇犖÷犖犢犖迦犖犢犖犖犢犖犖犖犢犖迦犖謹犖犖謹 Controller 犢犖犢犖犢犖犖
犖犢犖迦犖謹犖犖謹犖犖犖萎犖犖犖犖犖犖犢犖犖÷弦犖ム犖朽犖犖萎犖犖劇犖犖÷犢犖犖犖園 Model
by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111
Saturday, June 1, 13
Model-View-Controller (MVC)
- Controller
犢犖犢犖 Class 犖犖朽犖犖犢犖迦犖犖謹犖犢犖犖劇犖犢犖犖劇犖犖÷犢犖犖犖萎見犖о犖迦 Model 犖犖園View 犢犖犢犖
Class UIViewController 犢犖ム鍵犖犖о犖犖伍検 Flow 犖犖迦牽犖犢犖迦犖迦犖犖犖犢犖犖犢犖犖犖
by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111
Saturday, June 1, 13
Model-View-Controller (MVC)
Decrease Spaghetti codes
犢犖犢犖犖犖迦牽犖犖犖犢犖犖犢犖犖犖犖犖犢犖迦犖犖迦牽犖犢犖迦犖迦犖犖犖犢犖犖犢犖犖犖÷犖犢犖 3 犖犢犖о
犢犖犖劇犖犖ム犖犖о顕犖÷権犖伍犖犢犖犖∇鹸犖犖犖犖 code 犖犖朽 link 犖犖犖劇賢犖犖園犖犖園犢犖犖÷顕犢犖 Class
犢犖犖朽権犖о犖犖犢犖犢犖 犖犖犖迦犖犖犖犖
by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111
Saturday, June 1, 13
Model-View-Controller (MVC)
Avoid Monster Class
犖犖ム元犖犢犖ム元犢犖∇犖犖迦牽犖犖犢犖迦 Monster Class 犢犖犖 Class 犢犖犖朽権犖о犢犖迦見犖犢犖迦見犖ム顕犖
犖犖∇犖迦犖犖園犖犢犖犢 犢犖犢犖犖犢犖犖÷弦犖 犢犖犖犖犖犖 犖犖о犖犖伍検View 犖犢犖迦 犢 犢犖犖犖園硯犢犖犖
犢犖犖劇犖犖犖犖迦犢犖÷犖犖迦検犖迦牽犖犖犢犖 code 犢犖犢犖犢犢犖犖÷犢犖犢犖犢犖迦権
by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111
Saturday, June 1, 13
Model-View-Controller (MVC)
- ( Easy to maintain ) 犢犖犖∇犖迦牽犢犖∇犖犖犢犖迦犖朽犢犖犢犖ム鍵犖犢犖о犖犖園犢犖犖犖犢犖о権犢犖犢
犢犖犢犢犖犢犖犖犢犖犖犖÷犖犢犖犢犖迦権犖犖迦権犖犖ム険犖 犢犖犖劇犖犖犖犖迦犖÷元犖犢犖о犢犖犖劇犖犖÷犢犖犖犖園犖犢犖犖∇献犖
- ( Reuseabilty) 犖犖迦牽犢犖∇犢犖犢犖ム鍵犖犢犖о犖犖園犢犖犖犖犢犖о権犢犖犢犖犖迦検犖迦牽犖犢犖犖巌犖犖迦牽犖犢犖
Code 犢犖犢犖犢犢犖犢犢犖迦犖犖÷犢犖犢 犖犖犖劇賢犖犢犖迦犖犖迦犖犢犖犢犖犖朽犖犖劇犖犢犖犢
- 犖犖迦牽犖犢犖迦犖犢犖犢犖犢犢犖迦犖犖÷犖犢犖迦犖犢犢犖犖朽権犖 Code 犖犢犖犖∇献犖
by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111
Saturday, June 1, 13
Reuseabilty
- Model
犖犖о顕犖÷犖朽犖犖犖犖犖迦牽犖犢犖迦犖犢犖犢犢犖犖÷ : 犖犢犖犖
- View
犖犖о顕犖÷犖朽犖犖犖犖犖迦牽犖犢犖迦犖犢犖犢犢犖犖÷ : 犖犖迦犖犖ム顕犖
- Controller
犖犖о顕犖÷犖朽犖犖犖犖犖迦牽犖犢犖迦犖犢犖犢犢犖犖÷ : 犖犢犖犖∇検犖迦
by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111
Saturday, June 1, 13

More Related Content

iOS Basic Development Day 2 - Objective-C 2.0 & iOS Framework

  • 1. iPhone Developer Basic Program Day 2 Objective-C 2.0 by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111 Saturday, June 1, 13
  • 2. Course Outline 1. Introduction & Xcode 2. Objective-C & Frameworks 3. View &ViewController 4. View &ViewController (2) 5. Submit App Store Course Outline by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111 Saturday, June 1, 13
  • 3. www.ibluecode.com/training.html Day 1 - 5 際際滷 www.slideshare.net/eakkattiya Additional Course eakkattiya@gmail.com 086-6732111 twitter.com/eakkattiya facebook.com/eakapong.kattiya Resources by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111 Saturday, June 1, 13
  • 4. Object-Oriented Programming Objective-C 2.0 Developing iOS Apps : Language http://tinyurl.com/o54n8jd by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111 Saturday, June 1, 13
  • 5. Objective-C 2.0 by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111 犢犖犖迦犖о牽犢犖犖巌犖÷犖犖朽権犖犖犖項犖犖萎犖犖犢犖迦 ? - Class & Object ( 犖犖ム顕犖 & 犖犖犖犢犖犢犖 ) - Inheritance 犖犖迦牽犖犖劇犖犖犖犖犖ム顕犖 / Subclass 犖犖ム顕犖犖ム弦犖 - Interface and Implementation - Method & Property - Alloc & init Class & Object Inheritance & Subclass Interface & Implementation Method & Property Instantiation Saturday, June 1, 13
  • 6. Objective-C 2.0 : Class vs. Object by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111 Class = 犢犖犖犢犖犖ム犖犖犖劇賢犖犖巌検犖犢犢犖犖朽権犖/犖犖犖巌犖犖犖犖о険犖犖犖 Object = 犖о険犖犖犖 Class ------ Implement -----> Object 犖犖ム顕犖 (犢犖÷犢犖犖) ------ 犖犢犖迦犖犖犖犢犖迦犢犖犢犖 ---> 犖о険犖犖犖 Saturday, June 1, 13
  • 7. Objective-C 2.0 : Class vs. Object by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111 UIView *myView ; ClassName *objectName ; Framework <UIKit> 犖犖謹犖犖犢犖犖犢犖о権犖犖園硯犢犖ム犖犢犖犖÷賢犖犖謹犖犖犢犖犖犢犖о権犖犖園硯犢犖犖犢犢犖犖÷賢 Saturday, June 1, 13
  • 8. Objective-C 2.0 : Primitive Types (犖犖園硯犢犖犖犢犖犢犖犖犢犖迦犖劇犖犖犖迦) by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111 BOOL isCorrect = NO ; //YES NSInteger myInteger = 1234 ; CGFloat myFloat = 123.40 ; double myDouble = 123.40 ; Objective-C 2.0 : Value Object Types (犖犖園硯犢犖犖犢犖犢犖犖犢犖迦犖劇犖犖犖迦 + Method) NSNumber *number = @1234 ; NSString *name = @"world" ; NSString *greeting = [NSString stringWithFormat:@"Hello, %@ , %d", name, [number integerValue]]; Saturday, June 1, 13
  • 9. Objective-C 2.0 : If Else Condition (犢犖犖劇犖犖犢犖) by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111 NSString *name = @"world" ; BOOL isCorrect = [name isEqualToString:@"world"]; //Method if(isCorrect){ //Block NSLog(@"Welcome %@",name); }else{ NSLog(@"Wrong user name"); } Saturday, June 1, 13
  • 10. Objective-C 2.0 : NSArray (犢犖犢犢犖犖犢犖犖÷弦犖ム犖÷犢犖犢) by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111 // Compose a static array of string objects NSString *objs[3] = {@"One", @"Two", @"Three"}; // Create an array object with the static array NSArray *arrayOne = [NSArray arrayWithObjects:objs count:3]; // Create an array with a nil-terminated list of objects NSArray *arrayTwo = [NSArray arrayWithObjects:@"One", @"Two", @"Three", nil]; NSArray *arrayThree = @[ @"Hello World", @67, [NSDate date] ]; // get second object in array @67 NSNumber *two = [arrayThree objectAtIndex:1]; Objective-C 2.0 : NSMutableArray (犢犖犢犢犖犖犢犖犖÷弦犖ム犖犢) NSMutableArray *mutableArray = [NSMutableArray new]; [mutableArray addObject:@"First"]; [mutableArray removeObjectAtIndex:0]; Saturday, June 1, 13
  • 11. Objective-C 2.0 : NSDictionary (犢犖犢犢犖犖犢犖犖÷弦犖ム犖÷犢犖犢) by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111 NSDictionary *myDict = [NSDictionary dictionaryWithObjectsAndKeys:@"eak",@"name", @10,@"age", YES,@"isPass", nil]; NSString *name =[myDict valueForKey:@"name"] ; Objective-C 2.0 : NSMutableDictionary (犢犖犢犢犖犖犢犖犖÷弦犖ム犖犢) NSMutableDictionary *myDict = [NSMutableDictionary dictionaryWithObjectsAndKeys:@"eak",@"name", @10,@"age", YES,@"isPass", nil]; [myDict setValue:@100 forKey:@"score"] ; NSString *score = [myDict valueForKey:@"score"]; Saturday, June 1, 13
  • 12. 犖犖迦牽犖犖劇犖犖犖犖犖ム顕犖 Inheritance & Subclass 1. 犖犖ム顕犖 犖犖伍犖犖園硯犖犢犖犖犖÷元犖犖迦牽犖犖劇犖犖犖犖犖迦 犖犖ム顕犖犢犖÷ (Super class) 犢犖犢犖 UILabel 犖犖劇犖犖犖犖÷顕犖犖迦 UIView 2. 犖∇犢犖о犖 犖犖ム顕犖 NSObject 犢犖犖劇犖犖犖犖迦犢犖犢犖犖犖ム顕犖犢犖÷犖犖犖犖犖伍犖犖園硯 by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111 Saturday, June 1, 13
  • 13. Objective-C 2.0 : Interface & Implementation by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111 Saturday, June 1, 13
  • 14. Objective-C 2.0 : Interface (.h 鍖le) by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111 @interface classname : superclassname { // instance variables NSString *userInput ; } // Class Property @property (weak, nonatomic) IBOutlet UILabel *myLabel; @property (weak, nonatomic) NSString *name ; + classMethod1; + (return_type)classMethod2; + (return_type)classMethod3:(param1_type)param1_varName; - (return_type) instanceMethod1With1Parameter:(param1_type)param1_varName; - (return_type)instanceMethod2With2Parameters:(param1_type)param1_varName param2_callName:(param2_type)param2_varName; @end Saturday, June 1, 13
  • 15. Objective-C 2.0 : Implementation (.m 鍖le) by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111 @implementation classname + (return_type)classMethod { // implementation } - (return_type)instanceMethod { // implementation } @end Saturday, June 1, 13
  • 16. Objective-C 2.0 : Messages (Method) by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111 @implementation classname - (void)viewDidLoad { [super viewDidLoad]; //Call Method [self changeColorToRed:5.0 green:2.0 blue:6.0]; } // Method implementation - (void)changeColorToRed:(float)red green:(float)green blue:(float)blue{ UIColor *color = [UIColor colorWithRed:red green:green blue:blue alpha:1.0]; [self.view setBackgroundColor:color]; } Saturday, June 1, 13
  • 17. Objective-C 2.0 : Instantiation (犖犖迦牽犖犖犢犖迦 Object) by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111 MyClass *myObject1 = [[MyClass alloc]init]; [myObject1 setName:@"Hello"]; myObject1.name = @"Hello"; MyClass *myObject2 = [MyClass new]; [myObject2 setName:@"Hello"]; MyClass *myObject3 = [[MyClass alloc]initWithString:@"Hello"]; Saturday, June 1, 13
  • 18. Developing iOS Apps : Frameworks by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111 Saturday, June 1, 13
  • 19. Developing iOS Apps : Frameworks by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111 Saturday, June 1, 13
  • 20. Developing iOS Apps : Frameworks by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111 Saturday, June 1, 13
  • 21. http://www.apple.com/ios/ios6/ Developing iOS Apps : Frameworks by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111 Saturday, June 1, 13
  • 22. Developing iOS Apps : Design Patterns Model-View-Controller Target-Action Delegation Block Objects Protocol Noti鍖cation Center Key-Value Observing (KVO) http://tinyurl.com/o8pnof9 by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111 Saturday, June 1, 13
  • 23. Model-View-Controller (MVC) by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111 Saturday, June 1, 13
  • 24. Model-View-Controller (MVC) by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111 Saturday, June 1, 13
  • 25. by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111 Saturday, June 1, 13
  • 26. Model-View-Controller (MVC) Model 犢犖犢犖 Class 犖犖朽犖犖犢犖迦犖犖謹犖犢犖犖劇犖犢犖犢犢犖犢犖犖犢犖犖÷弦犖ム犖犖犢犖犖犢犖犖犖 犢犖犢犖 Class Contacts 犢犖犢犖犖犖迦権犖犖劇犖 犢犖犖犖犢犢犖犖 犖犖項犖犖巌犖犢犖 犢犖犖∇犖÷犖犢犖迦犖犢犖犖犢犖犖犖犢犖迦犖謹犖犖謹View 犢犖ム鍵 Controller by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111 Saturday, June 1, 13
  • 27. Model-View-Controller (MVC) - View 犢犖犢犖 Class 犖犖朽犖犖犢犖迦犖犖謹犖犢犖犖劇犖犢犖犖犖犖犖ム犖犖犖犢犖迦犖 犢犖犢犖 UIView , UILabel , UITextField 犢犖犖∇犖÷犖犢犖迦犖犢犖犖犢犖犖犖犢犖迦犖謹犖犖謹 Controller 犢犖犢犖犢犖犖 犖犢犖迦犖謹犖犖謹犖犖犖萎犖犖犖犖犖犖犢犖犖÷弦犖ム犖朽犖犖萎犖犖劇犖犖÷犢犖犖犖園 Model by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111 Saturday, June 1, 13
  • 28. Model-View-Controller (MVC) - Controller 犢犖犢犖 Class 犖犖朽犖犖犢犖迦犖犖謹犖犢犖犖劇犖犢犖犖劇犖犖÷犢犖犖犖萎見犖о犖迦 Model 犖犖園View 犢犖犢犖 Class UIViewController 犢犖ム鍵犖犖о犖犖伍検 Flow 犖犖迦牽犖犢犖迦犖迦犖犖犖犢犖犖犢犖犖犖 by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111 Saturday, June 1, 13
  • 29. Model-View-Controller (MVC) Decrease Spaghetti codes 犢犖犢犖犖犖迦牽犖犖犖犢犖犖犢犖犖犖犖犖犢犖迦犖犖迦牽犖犢犖迦犖迦犖犖犖犢犖犖犢犖犖犖÷犖犢犖 3 犖犢犖о 犢犖犖劇犖犖ム犖犖о顕犖÷権犖伍犖犢犖犖∇鹸犖犖犖犖 code 犖犖朽 link 犖犖犖劇賢犖犖園犖犖園犢犖犖÷顕犢犖 Class 犢犖犖朽権犖о犖犖犢犖犢犖 犖犖犖迦犖犖犖犖 by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111 Saturday, June 1, 13
  • 30. Model-View-Controller (MVC) Avoid Monster Class 犖犖ム元犖犢犖ム元犢犖∇犖犖迦牽犖犖犢犖迦 Monster Class 犢犖犖 Class 犢犖犖朽権犖о犢犖迦見犖犢犖迦見犖ム顕犖 犖犖∇犖迦犖犖園犖犢犖犢 犢犖犢犖犖犢犖犖÷弦犖 犢犖犖犖犖犖 犖犖о犖犖伍検View 犖犢犖迦 犢 犢犖犖犖園硯犢犖犖 犢犖犖劇犖犖犖犖迦犢犖÷犖犖迦検犖迦牽犖犖犢犖 code 犢犖犢犖犢犢犖犖÷犢犖犢犖犢犖迦権 by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111 Saturday, June 1, 13
  • 31. Model-View-Controller (MVC) - ( Easy to maintain ) 犢犖犖∇犖迦牽犢犖∇犖犖犢犖迦犖朽犢犖犢犖ム鍵犖犢犖о犖犖園犢犖犖犖犢犖о権犢犖犢 犢犖犢犢犖犢犖犖犢犖犖犖÷犖犢犖犢犖迦権犖犖迦権犖犖ム険犖 犢犖犖劇犖犖犖犖迦犖÷元犖犢犖о犢犖犖劇犖犖÷犢犖犖犖園犖犢犖犖∇献犖 - ( Reuseabilty) 犖犖迦牽犢犖∇犢犖犢犖ム鍵犖犢犖о犖犖園犢犖犖犖犢犖о権犢犖犢犖犖迦検犖迦牽犖犢犖犖巌犖犖迦牽犖犢犖 Code 犢犖犢犖犢犢犖犢犢犖迦犖犖÷犢犖犢 犖犖犖劇賢犖犢犖迦犖犖迦犖犢犖犢犖犖朽犖犖劇犖犢犖犢 - 犖犖迦牽犖犢犖迦犖犢犖犢犖犢犢犖迦犖犖÷犖犢犖迦犖犢犢犖犖朽権犖 Code 犖犢犖犖∇献犖 by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111 Saturday, June 1, 13
  • 32. Reuseabilty - Model 犖犖о顕犖÷犖朽犖犖犖犖犖迦牽犖犢犖迦犖犢犖犢犢犖犖÷ : 犖犢犖犖 - View 犖犖о顕犖÷犖朽犖犖犖犖犖迦牽犖犢犖迦犖犢犖犢犢犖犖÷ : 犖犖迦犖犖ム顕犖 - Controller 犖犖о顕犖÷犖朽犖犖犖犖犖迦牽犖犢犖迦犖犢犖犢犢犖犖÷ : 犖犢犖犖∇検犖迦 by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111 Saturday, June 1, 13