클레스 정의
Classes Are Blueprints for Objects
Basic Syntax
@interface SimpleClass : NSObject
// do something
@end
Properties Control Access to and Object's Values
@interface Person : NSObject
@property NSString *firstName;
@property NSString* lastName;
@end
-> 이것도 알아 두기
@property NSNumber *yearOfBirth;
@property int yearOfBirth;
@property NSInteger myInteger;
Property Attributes Indicate Data Accessibility and Storage Considerations
all declare properties that are intended for complete public access.
@interface Person : NSObject
@property (readonly) NSString *firstName;
@property (readonly) NSString *lastName;
@end
Method Declarations Indicate the Messages an Object Can Receive
void SomeFunction();
-> - (void)someMethod;
-: for instance method, +: for static method
Methods Can Take Parameters
void SomeFunction(SomeType value);
-> - (void) someMethodWithValue: (SomeType) value;
void SomdFunction(SomeType value1, SomeType value2)
-> - (void) someMethodWithValue: (SomeType) value1 secondValue:(SomeType) value2;
Class Names Must Be Unique
당연하지
Basic Syntax
#import "XYZPerson.h"
@implementation XMYPerson
@end
Implementing Methods
@interface XYZPerson : NSObject
- (void) sayHello;
@end
#import "XYZPerson.h"
@implementation XYZPerson
- (void)sayHello {
NSLog(@"Hello, World!");
}
@end
'Objective-C' 카테고리의 다른 글
Introduction (0) | 2016.05.10 |
---|