摘要: 第一个字符串://必须在字符串的前面加上@符号, NSString* str=@"shouqiang_Wei";//输出以%@输出。NSLog(@"%@",str);结果:2013-08-21 14:06:22.963 NSNumber[611:707] shouqiang_WeiNSString 类原型: 1 @interface NSString : NSObject 2 3 /* NSString primitive (funnel) methods. A minimal subclass of NSString just needs to imp 阅读全文
posted @ 2013-08-21 20:11 shouqiang Wei 阅读(1245) 评论(0) 推荐(0) 编辑
摘要: 1 #import 2 //xieyi 3 @protocol showOn 4 @required 5 -(void)printOn; 6 @end 7 // lei 8 @interface MyPoint : NSObject{ 9 int x;10 int y;11 }12 @property (nonatomic,assign)int x,y;13 -(id)initWithX:(int)_x andY:(int)_y;14 @end15 // leibie fenlei16 @interface MyPoint(MoveSet)17 18 -(void)mov... 阅读全文
posted @ 2013-08-21 16:33 shouqiang Wei 阅读(364) 评论(0) 推荐(0) 编辑
摘要: 1 #import 2 //xieyi 3 @protocol showOn 4 @required 5 -(void)printOn; 6 @end 7 // lei 8 @interface MyPoint : NSObject{ 9 int x; 10 int y; 11 } 12 @property (nonatomic,assign)int x,y; 13 -(id)initWithX:(int)_x andY:(int)_y; 14 @end 15 // leibie fenlei 16 @interface MyPoint(MoveSet)... 阅读全文
posted @ 2013-08-21 16:31 shouqiang Wei 阅读(226) 评论(0) 推荐(0) 编辑
摘要: 实现Square类,让其继承自Rectangle类,并在Square类增添新属性和方法,在2的基础上,在Square类中重写Rectangle类中的初始化和打印方法 1 #import 2 3 @interface Rectangle : NSObject{ 4 int width; 5 int height; 6 } 7 @property int width,height; 8 -(int) area; 9 -(int) perimeter;10 -(void)setWidth:(int)w andHeight:(int)h;11 -(void)print;12 13 ... 阅读全文
posted @ 2013-08-21 16:18 shouqiang Wei 阅读(763) 评论(0) 推荐(0) 编辑
摘要: 1 #import 2 3 @interface Rectangle : NSObject{ 4 int width; 5 int height; 6 } 7 @property int width,height; 8 -(int) area; 9 -(int) perimeter;10 -(void)setWidth:(int)w andHeight:(int)h;11 12 @end13 14 15 #import "Rectangle.h"16 17 @implementation Rectangle18 @synthesize width,height;19 -(. 阅读全文
posted @ 2013-08-21 16:17 shouqiang Wei 阅读(383) 评论(0) 推荐(0) 编辑
摘要: 1 #import 2 @protocol show 3 @required 4 -(void)printOn; 5 @end 6 7 @interface XYPoint : NSObject{ 8 int x; 9 int y;10 }11 @property (nonatomic,assign)int x,y;12 -(id)setX:(int)_x andY:(int)_y;13 14 @end15 16 #import "XYPoint.h"17 18 @implementation XYPoint19 @synthesize x,y;20 21 -(id)se. 阅读全文
posted @ 2013-08-21 16:15 shouqiang Wei 阅读(245) 评论(0) 推荐(0) 编辑
摘要: 2013-08-21在Objective-C,包括int double float 等等再内的基础数据类型都不是一个类,所以就不能给它们发送消息,也就是说不能调用方法,那怎么办呢 ?Objective-C提供了一个NSNumber类来作为一个中转,可以将所有的普通数据类型转化为NSNumber类型,这样就符合Objective-C的消息机制了。NSNumber #import int main (int argc, const char * argv[]){ @autoreleasepool { //初始化NSNumber使用格式: numberWith+... 阅读全文
posted @ 2013-08-21 13:56 shouqiang Wei 阅读(567) 评论(0) 推荐(0) 编辑