fly121121

班级

TA还未加入任何班级

课程

2万+浏览/ 670学员/ 5评分
kent
免费
移动开发 IOS开发入门教程
17万+浏览/ 7252学员/ 4.1评分
3万+浏览/ 2346学员/ 4.5评分
3万+浏览/ 726学员/ 4评分

笔记

来自如何创建你自己的定制类(0)

@interface Person : NSObject{    NSString *name;    int age;}- (NSString *)name; //get method- (void)setName:(NSString *)value;- (int) age; //get method;- (void)setAge:(int)age;- (BOOL)canLegallyVote;//another way to creat property//property declarations@property int age;@property (copy) NSString *name;@property (readonly) BOOL canLegallyVote; - (void)castBallot;@end // implementation file@implementation Person;- (int) age {return age;}- (void)setAge:(int) value{    age=value; } - (NSString *) name {return name;}- (void)setName:(NSString *) value{    name=value;} //calling method- (BOOL)canLegallyVote {     return (self age>=18);}//antoher way to write it@synthesize age;@synthesize name;- (BOOL)canLegallyVote{    return(age >18);}   - (void)castBallot {   if([self canLegallyVote]){     //do voting stuff}else {    NSLog(@"I'm not allowed to vote yet!");}}}   @end // Autoreleasing example- (NSString *)fullName{      NSString *result;      result=[[NSString alloc] initWithFormat:"%@ %@" , firstName, lastName];      [result autorelease];       return result;}   

留言

功能维护升级中,维护完成完后将再次开放,非常抱歉给您学习造成的不便。