您的位置:首页 > 移动开发 > Objective-C

object-c 学习小记

2010-08-03 14:48 141 查看
leibie

申明

@interface NSString(NumberConvenience)

-(NSNumber *)lenthAsNumber;

@end

实现

@implementation NSString(NumberConvenience)

-(NSNumber *)lenthAsNumber{

unsigned int length = [self length];

return ([NSNumber numberWithUnsignedint : length]);

}

@end

正式协议

申明

@protocol myprotocol

-(id) someprotocol : (NSString *)zone;

@optional

-(void)method1;

@required

-(void)mthod2;

@end

采用

@interface myClass: NSOject<myprotocol, otherprotocol>

{

}

@end

特性

申明 @property(attributes) type name;

@interface myclass : someclass

{

int someproperty;

}

@property int someproperty;

@property float otherproperty;

@end

实现

@implementation myclass

@synthesize someproperty;

@synthesize property1 = otherproperty;

@end
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: