p.119
Attribute of a property
the declaration of a property
@property (attributes) type name;
The attributes can include readwrite(the default) or readonly. A property marked readonly gets no setter method.
To describe how the setter method should work, the attributes can also include one of the following: assign, retain, copy.
- assign(the default) makes a simple assignment happen. assign does not retain the new value. If you are dealing with an object type and you are not using the garbege collector, you probably don’t want assign.
- retain releases the old value and retains the new value. This attribute is used only for Objective-C object types. If you are using the garbage collector, assign and retain are equivalent.
- copy makes a copy of the new value and assigns the variable to the copy. This attribute is often used for properties that are strings.
The attributes can also include nonatomic.
p.142
When designing a class, I tend to think of my instance variables as having one of four possible purposes:
1. Simple attributes.
- Simple attributes are typically numbers or instances of NSString, NSDate, or NSData.
2. To-one relationships.
- To-one relationships are implemented using pointers: An instance of Student has a pointer to an instance of School.
3. Ordered to-many relationships.
- Relationships of this kind are typically implemented using an NSMutableArray.
4. Unordered to-many relationships.
- This order is typically implemented using an NSMutableSet.
p.145
- Key-value cording is a way to read and change a variable’s value by using its name.
- Key-value observing allow you to be informed when these sorts of changes occur.
フィードバックはありません。 これまで ↓
コメントはまだありません。以下のフォームに記入して会話を始めてみましょう。