1.养成在方法和类的大括号后边加名称注释的习惯。
2.Objective-C does not support multiple inheritance。
3.继承是在interface里边做,implementation不管这个,只管实现或者重写。
4.super的使用,用于修改被继承类的基本域。例如
@implementation Circle
- (void)setFillColor:(ShapeColor)c
{
if (c == kRedColor)
{
c = kGreenColor;
}
[super setFillColor: c];
} // setFillColor
5.关于implementation中私有方法的使用
可以直接在interface中不声明,然后在implementation中导入。@interface Tire : NSObject @end // Tire
@implementation Tire - (NSString *) description {
return (@"I am a tire. I last a while."); } // description @end // Tire
6.An accessor method is one that reads or changes a specific attribute for an object.
例如:@interface Car : NSObject {
Engine *engine;
Tire *tires[4]; }
- (Engine *) engine; - (void) setEngine: (Engine *) newEngine; - (Tire *) tireAtIndex: (int) index;
- (void) setTire: (Tire *) tire atIndex: (int) index; - (void) print; @end // Car
7.方法分开写不是两个方法,而是一个方法分开写之后会更容易读一些
例如-(void) speak:(NSString) word toPerson:(NSString) name;
8.Source File Orgnization,dot-h-file 用来记录类的声明,dot-m-file用来记录实现的过程。
9.If you use .mm for the file extension, you’re telling the compiler you’ve written your code inObjective-C++, which lets you use C++ and Objective-C together.
10.@class theClass;当在一个类的声明中需要用到另一个类的时候,可以用#import “theClass”,也可以用@class theClass;但是同时要注意,Because we’re inheriting from these classes rather than just using pointers to the classes, we can’t use the @class trick intheir header files. 继承的时候不能用.
11.When you declare a method with the plus sign, you’ve marked the method as a class method.This method belongs to the class object (as opposed to an instance object of the class) and istypically used to create new instances. Class methods used to create new objects are calledfactory methods.
12.+号方法是类方法,主要有两种用途,一种是创建事物,另一种是使用工具方法的时候,例如return。。。