當前位置:編程學習大全網 - 網站源碼 - Object-C 聲明屬性為什麽用下劃線,代碼規範和編程風格

Object-C 聲明屬性為什麽用下劃線,代碼規範和編程風格

常是以這種方式來做的:

*.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中

  • 上一篇:網站的源代碼怎樣修改,我的網站是買的後臺沒這個功能
  • 下一篇:thinkphp如何對mysql進行分區
  • copyright 2024編程學習大全網