Created
January 7, 2014 03:02
-
-
Save keicoder/8294050 to your computer and use it in GitHub Desktop.
objective-c : 오브젝트와 클래스의 차이
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| distinction between an object and its class | |
| //ice cream class | |
| @interface IceCream : NSObject @property (nonatomic, strong) NSString *flavor; | |
| @property (nonatomic, assign) int scoops; | |
| - (void)eatIt; | |
| @end | |
| // two instances of IceCream, one for you and one for me | |
| // one class, IceCream, but there are two distinct objects. | |
| // Your object has strawberry flavor, mine pistachio. | |
| // one for you | |
| IceCream *iceCreamForYou = [[IceCream alloc] init]; | |
| iceCreamForYou.flavor = @"Strawberry"; | |
| iceCreamForYou.scoops = 2; | |
| // and one for me | |
| IceCream *iceCreamForMe = [[IceCream alloc] init]; | |
| iceCreamForMe.flavor = @"Pistachio"; | |
| iceCreamForMe.scoops = 3; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment