@implementation ClassName : ItsSuperclass {
instance variable declarations
#import "ClassName.h" @implementation ClassName method definitions @end
语言函数,使用方法声明中同样的命 名格式,以一对大括号来括起具体的实现代码:
- (void)setFilled:(BOOL)flag {
This is illustrated in Figure 2-1. Figure 2-1 The scope of instance variables
A directive applies to all the instance variables listed after it, up to the next directive or th the following example, the age and evaluation instance variables are private, name , jo protected, and boss is public.
The class that declares the instance variable
@private 私有:只有类定义内部可访问 @private
inherits the instance variable
@interface Worker : NSObject {
@interface Worker : NSObject {
变量可不通过访问器直接访问,前提是对象已经 被指定为静态类型:
Worker *ceo = [[Worker alloc] init]; ceo->boss = nil;
self :执行方法的对象本身 super :调用对象的父类中的实现来执行方法
除了可以用作向自身请求方法以外,还可以作为一 个代表对象本身的隐藏变量来使用
只能出现在消息表达式中,代表了对被复写的方 法的原始实现的请求方式