Re: KVC on an array in an NSDictionary
Re: KVC on an array in an NSDictionary
- Subject: Re: KVC on an array in an NSDictionary
- From: Ondra Cada <email@hidden>
- Date: Tue, 18 Apr 2006 23:58:41 +0200
Scott,
On 18.4.2006, at 23:38, Scott Ellsworth wrote:
I then call
[self setValue:newArray
forKey:@"data.newElementAddedeEveryMinuteAtSecond5"]
This works. The array has been replaced by a new one, all the
views get their notifications fired, and everyone is happy.
I am not pleased, though, that I am creating a brand new array
every time through, when all I really want to do is to update the
data by an item.
Is there a KVC-compliant way to remove element zero and add a new
element at the end of an NSMutableArray that will keep KVB/O
notifications working?
The proper solution should be
id ma=[self
mutableArrayValueForKeyPath:@"data.newElementAddedeEveryMinuteAtSecond5"
];
[ma addObject:newElement];
[ma removeObjectAtIndex:0];
Is there a catch that if the array lays inside an NSMutableDictionary
it does not work properly? I haven't tried myself. But it should.
---
Ondra Čada
OCSoftware: email@hidden http://www.ocs.cz
private email@hidden http://www.ocs.cz/oc
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden