mardi 3 février 2015

Updating a class with readonly properties in Objective-C

What is a good pattern for creating and updating a class with readonly properties? An example for such a class



@interface ReadOnlyClass : NSObject

@property (nonatomic, assign, readonly) NSUInteger number;

@end


It is not necessary for the class user to call the init constructor (although this is not really possible to avoid in Objective-C) or anything else. Apple uses this pattern e.g. in CMLogItem or CLLocation. So, how can I change/update the value of number in a good manner?


Aucun commentaire:

Enregistrer un commentaire