第3章 Object c
来源:互联网 发布:搜索引擎快速排名软件 编辑:程序博客网 时间:2024/06/06 16:37
第3章
3.1 basic grammar
object c is a extension of c.
it's basic grammer is that:
[object_receiver message]
ex. [NSMutableArray alloc]
[object_receiver messageparam1:param1 messageparam2:param2]
ex. [x intersectsArcWithRadius:35.0 centeredAtX:19.0 Y:23.0 fromAngle:90.0 toAngle:120.0]
object c string = @"string"
3.2 basic class
NSObject
^
|
|---------------|
NSArray NSString
^
|
|
NSMutableArray
NSObject:
-(id)init
[[NSObject alloc] init]
-(NSString *)descprition
NSLog(@"the number at index %d is %@", i, object)
-(BOOL)isEqual: (id)anObject
NSMutableArray
mutable means not const, once the object is created, it can be add and remove.
3.3 we should use "uses and knows about" more than "inherit from"
3.4 make lottery class of my own.
1)define a new class, and add the object to the Array. print the array, it is not the way we expect.
2)introduce NSCalendarDate
+(id)calendarDate: + means class method , we can use it as [NSCalendarDate calendarDate]
3)write initializers
(1)basic init
-(id)init
{
[super init];
your methods;
return self;
}
(2)initializers with arguments
-(id)initWithEntryDate: (NSCalendarDate *)theDate
{}
(3)the protect from ignorance, override the basic initialzer
-(id)init
{
return [self initWithEntryDate:[NSCalendarDate calendarDate]];
}
3.5 debug
cocoa application 断点无效, 但是iphone:windows based application 可以。暂时不影响iphone程序的调试。
- 第3章 Object c
- Object-C 第三天
- Object-C 学习第一天
- 认识object-c第一天
- ios 学习第一天 object-c入门
- 第一篇 Object-C快速入门
- 第一篇 Object-C快速入门
- 第一篇 Object-C快速入门
- 第一篇 Object-C快速入门
- 第二章 object-c
- object-c(3)
- object-C总成3
- MOCK object-第7章
- 第6章 helper object
- object-c 学习第一天(windows编译环境配置)
- object-c 学习第三天(方法和消息)
- object-c 学习第五天(对象块)
- object-c 学习第三天(方法和消息)
- android博客推荐
- tmux快捷键
- 第6章 6_1、6_2、6_3习题
- 学习cocoa编程-.Cocoa.Programming
- CentOS下用openldap管理samba和账号登录
- 第3章 Object c
- 使用ios系统自带的MapKit framework进行定位
- 第4章 memory management
- 应聘常见问题分析
- 第5章 target/action
- Socket模型详解
- uva-489 - Hangman Judge
- C语言实现内存池 (转)
- 第6章 helper object