kvc/kvo for arrays defeated me.
kvc/kvo for arrays defeated me.
- Subject: kvc/kvo for arrays defeated me.
- From: Darren Minifie <email@hidden>
- Date: Fri, 13 Mar 2009 15:34:29 -0700
Hi Everyone.
I'm hoping to get a little help when it comes to binding a table to an array
through an array controller. The table is loading the proper values which
leads me to believe that my getter is working, but when i try to edit a
value, I receive a runtime error. I've found good posts on here about
needing to implement indexed accessor methods. I believe I've done that but
still no luck.
=== Interface file: ===
@interface PerceptionController : NSWindowController {
NSMutableArray* dpcm2;
}
@property(nonatomic, retain) NSMutableArray* dpcm2;
-(void)insertObject:(id)num inDpcm2AtIndex:(unsigned)index;
-(void)removeObjectFromDpcm2AtIndex:(unsigned)index;
-(void)replaceObjectInDpcm2AtIndex:(unsigned)index withObject:(id)num;
=== implementation file ===
@synthesize dpcm2;
-(id)init{
self = [super initWithWindowNibName:@"perceptionPanel"];
self.dpcm2 = [NSMutableArray arrayWithCapacity:6];
for(int i = 0; i<6; i++){
// just adding eight 0's to the array
[dpcm2 addObject:[NSNumber numberWithInt:0]];
}
return self;
}
-(void)insertObject:(id)num inDpcm2AtIndex:(unsigned)index{
[[self dpcm2] insertObject:num atIndex:index];
}
-(void)removeObjectFromDpcm2AtIndex:(unsigned)index{
[[self dpcm2] removeObjectAtIndex:index];
}
-(void)replaceObjectInDpcm2AtIndex:(unsigned)index withObject:(id)num{
[[self dpcm2] replaceObjectAtIndex:index withObject:num];
}
== end code ==
within interface builder, I have a table column bound to the arrangedObjects
property of an array controller. The array controller is bound to the dpcm2
array. Again, the getters are working, but setters arent. One resource I
found says this:
"For best performance, you should implement the two KVC-compliant methods
shown in the next listing, instead of the setShapes: method:". (its in:
Sample KVC-Compliant Accessor Methods apple docs). I dont understand why
they dont implement the setter for their property, and this may be the cause
of my problem. Without the setter method how do you ever assign something
to the property in the first place? The runtime error i receive when trying
to change a value is:
2009-03-13 15:33:36.142 a4[4494:10b] Error setting value for key path of
object 0 (from bound object <NSTableColumn: 0x187150>(null)): [<NSCFNumber
0x1105d0> setValue:forUndefinedKey:]: this class is not key value
coding-compliant for the key .
Thank you for any ideas you may have, and curing me of my ignorance.
--
Darren Minifie
Graduate Studies: Computer Science
www.myavalon.ca
www.ohsnapmusic.com
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden