Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [myObj addObserver:self forKeyPath:@"theArray" options:0 context:NULL];
- [myObj.theArray addObject:NSString.string];
- [[myObj mutableArrayValueForKey:@"theArray"] addObject:NSString.string];
- [myObject insertObject:newObject inTheArrayAtIndex:[myObject countOfTheArray]];
- - (void) addTheArrayObject:(NSObject *) newObject {
- [self insertObject:newObject inTheArrayAtIndex:[self countOfTheArray]];
- }
- [myObj addObserver:self forKeyPath:@"theArray.@count" options:0 context:NULL];
- - (NSMutableArray*) theMutableArray {
- return [self mutableArrayValueForKey:@"theArray"];
- }
- // Interface
- @property (nonatomic, strong, readonly) NSMutableArray *items;
- // Implementation
- @synthesize items = _items;
- - (NSMutableArray *)items
- {
- return [self mutableArrayValueForKey:@"items"];
- }
- // Somewhere else
- [myObject.items insertObject:@"test"]; // Will result in KVO notifications for key "items"
- - (void)addSomeObject:(id)object {
- self.myArray = [self.myArray arrayByAddingObject:object];
- }
- - (void)removeSomeObject:(id)object {
- NSMutableArray * ma = [self.myArray mutableCopy];
- [ma removeObject:object];
- self.myArray = ma;
- }
Add Comment
Please, Sign In to add comment