FROM : Hannes Petri
DATE : Mon Jul 17 11:19:38 2006
On 17 jul 2006, at 11:18, Hannes Petri wrote:
> Hello, I'm here again. After some responses, it was rather clear
> that what I tried to do isn't working. But I haven't given up yet,
> and now the problem is a little different.
>
> I've found this message:
> http://www.cocoabuilder.com/archive/message/cocoa/2004/12/1/122701
>
> I've created a wrapper around the array that i call
> CollectionsManager. This is the source code for it:
>
> - (id)init
> {
> if (self = [super init])
> {
> collections = [[NSMutableArray alloc] init];
> return self;
> }
> return nil;
> }
>
> - (void)insertObject:(id)object inCollectionsAtIndex:(int)index
> {
> [self didChange:NSKeyValueChangeInsertion valuesAtIndexes:
> [NSIndexSet indexSetWithIndex:index] forKey:@"collections"];
> [collections insertObject:object atIndex:index];
> [self didChange:NSKeyValueChangeInsertion valuesAtIndexes:
> [NSIndexSet indexSetWithIndex:index] forKey:@"collections"];
> }
>
> - (void)removeObjectFromCollectionsAtIndex:(int)index
> {
> [self willChange:NSKeyValueChangeRemoval valuesAtIndexes:
> [NSIndexSet indexSetWithIndex:index] forKey:@"collections"];
> [collections removeObjectAtIndex:index];
> [self didChange:NSKeyValueChangeRemoval valuesAtIndexes:
> [NSIndexSet indexSetWithIndex:index] forKey:@"collections"];
> }
>
> - (NSMutableArray *)collections
> {
> return collections;
> }
>
> - (int)countOfCollections
> {
> return [collections count];
> }
>
> - (CCICollection *)objectInCollectionsAtIndex:(int)index
> {
> return [collections objectAtIndex:index];
> }
>
> As you can see, it implements the indexed accessors methods. I
> observe it like this:
>
> [collectionsManager addObserver:collectionsView
> forKeyPath:@"collections"
> options:NSKeyValueObservingOptionNew|NSKeyValueObservingOptionOld
> context:NULL];
>
> The thread says that what I wanted from the beginning (see original
> message below) should work by doing this way. But it don't. What am
> I doing wrong this time? I've tried a lot now, but i cant find the
> solution.
>
> I would be very, very grateful if someone could help me.
>
>
> Hannes Petri
> <email_removed>
>
>> Hello!
>> I'm using KVO to observe an array controller, and when an object
>> is added, a view should be changed.
>> Now I want a pointer to the object that was added. How should I do?
>> Apples documentation says that I should get the index of the new
>> object, by querying the changes-dict with the key
>> NSKeyValueChangeIndexesKey, but that returns null.
>> What am I doing wrong? Is it possible to achieve what I want?
>>
>>
>> Hannes Petri
>> <email_removed>
>> Do not post admin requests to the list. They will be ignored.
>> Cocoa-dev mailing list (<email_removed>)
>> Help/Unsubscribe/Update your Subscription:
>> http://lists.apple.com/mailman/options/cocoa-dev/<email_removed>
>>
>> This email sent to <email_removed>
>
DATE : Mon Jul 17 11:19:38 2006
On 17 jul 2006, at 11:18, Hannes Petri wrote:
> Hello, I'm here again. After some responses, it was rather clear
> that what I tried to do isn't working. But I haven't given up yet,
> and now the problem is a little different.
>
> I've found this message:
> http://www.cocoabuilder.com/archive/message/cocoa/2004/12/1/122701
>
> I've created a wrapper around the array that i call
> CollectionsManager. This is the source code for it:
>
> - (id)init
> {
> if (self = [super init])
> {
> collections = [[NSMutableArray alloc] init];
> return self;
> }
> return nil;
> }
>
> - (void)insertObject:(id)object inCollectionsAtIndex:(int)index
> {
> [self didChange:NSKeyValueChangeInsertion valuesAtIndexes:
> [NSIndexSet indexSetWithIndex:index] forKey:@"collections"];
> [collections insertObject:object atIndex:index];
> [self didChange:NSKeyValueChangeInsertion valuesAtIndexes:
> [NSIndexSet indexSetWithIndex:index] forKey:@"collections"];
> }
>
> - (void)removeObjectFromCollectionsAtIndex:(int)index
> {
> [self willChange:NSKeyValueChangeRemoval valuesAtIndexes:
> [NSIndexSet indexSetWithIndex:index] forKey:@"collections"];
> [collections removeObjectAtIndex:index];
> [self didChange:NSKeyValueChangeRemoval valuesAtIndexes:
> [NSIndexSet indexSetWithIndex:index] forKey:@"collections"];
> }
>
> - (NSMutableArray *)collections
> {
> return collections;
> }
>
> - (int)countOfCollections
> {
> return [collections count];
> }
>
> - (CCICollection *)objectInCollectionsAtIndex:(int)index
> {
> return [collections objectAtIndex:index];
> }
>
> As you can see, it implements the indexed accessors methods. I
> observe it like this:
>
> [collectionsManager addObserver:collectionsView
> forKeyPath:@"collections"
> options:NSKeyValueObservingOptionNew|NSKeyValueObservingOptionOld
> context:NULL];
>
> The thread says that what I wanted from the beginning (see original
> message below) should work by doing this way. But it don't. What am
> I doing wrong this time? I've tried a lot now, but i cant find the
> solution.
>
> I would be very, very grateful if someone could help me.
>
>
> Hannes Petri
> <email_removed>
>
>> Hello!
>> I'm using KVO to observe an array controller, and when an object
>> is added, a view should be changed.
>> Now I want a pointer to the object that was added. How should I do?
>> Apples documentation says that I should get the index of the new
>> object, by querying the changes-dict with the key
>> NSKeyValueChangeIndexesKey, but that returns null.
>> What am I doing wrong? Is it possible to achieve what I want?
>>
>>
>> Hannes Petri
>> <email_removed>
>> Do not post admin requests to the list. They will be ignored.
>> Cocoa-dev mailing list (<email_removed>)
>> Help/Unsubscribe/Update your Subscription:
>> http://lists.apple.com/mailman/options/cocoa-dev/<email_removed>
>>
>> This email sent to <email_removed>
>
| Related mails | Author | Date |
|---|---|---|
| Hannes Petri | Jul 12, 00:43 | |
| Hannes Petri | Jul 12, 13:00 | |
| George Orthwein | Jul 12, 15:25 | |
| Hannes Petri | Jul 12, 15:56 | |
| Matt Neuburg | Jul 12, 19:35 | |
| Bill Northcott | Jul 13, 01:41 | |
| Matt Neuburg | Jul 13, 16:46 | |
| Hannes Petri | Jul 14, 12:41 | |
| Matt Neuburg | Jul 14, 17:47 | |
| George Orthwein | Jul 14, 22:22 | |
| Matt Neuburg | Jul 14, 22:32 | |
| Hannes Petri | Jul 17, 11:19 | |
| George Orthwein | Jul 18, 20:39 |






Cocoa mail archive

