*.h中申明變量
#import?<UIKit/UIKit.h>
@interface?NewPlayerController?:?UIViewController{
NSString?*test;
}
@property(nonatomic,retain)?NSString?*test;
@end
在*.m中
#import?"NewPlayerController.h"
@implementation?NewPlayerController
@synthesize?test;
-?(void)viewDidLoad
{
[super?viewDidLoad];
test=[[NSString?alloc]?initWithFormat:@"test"];
}
@end
但是,發現很多別人寫的代碼是這樣子的:
*.h中申明變量
#import?<UIKit/UIKit.h>
@interface?NewPlayerController?:?UIViewController{
NSString*?_test;
}
@property(nonatomic,retain)?NSString?*test;
@end
在*.m中