Apple のドキュメントhereを読むと、サンプル コードでは、プリミティブ アクセサーとミューテーターがカテゴリ内の個別のメソッドとして宣言されています。@property
プリミティブを宣言するために使用することは可能ですか? このようにすることの欠点はありますか; 定型コードを節約するように見えますが、このように宣言されたときにメソッドが生成される方法にパフォーマンスへの影響はありますか? オプションの属性は何ですか - (strong、nonatomic)?
Appleのサンプルコード
@interface Department : NSManagedObject
@property(nonatomic, retain) NSString *name;
@end
@interface Department (PrimitiveAccessors)
- (NSString *)primitiveName;
- (void)setPrimitiveName:(NSString *)newName;
@end
提案された変更
@interface Department : NSManagedObject
@property(nonatomic, retain) NSString *name;
@end
@interface Department (PrimitiveAccessors)
@property (strong, nonatomic) NSString *primitiveName;
@end