終於比較有空補完下集了!這一集主要想要分享Objective-C的直接存取與間接存取的差異,以及function return value 的 retain、release 時機。
首先先看下面一個很簡單的 student class:
student.h
@interface Student: NSObject {
NSString *iName;
NSString *iStudentID;
int age;
}
@property(nonatomic,copy) NSString *iName;
@property(nonatomic,copy) NSString *iStudentID;
@property(nonatomic,assign) int age;
@end
student.m
#import "student.h"
@implementation student
@synthesize iName,iStudentID,age;
- (void) dealloc {
[iName release];
[iStudentID release];
[super dealloc];
}
@end