Re: Bindings and C Array
Re: Bindings and C Array
- Subject: Re: Bindings and C Array
- From: Erik Buck <email@hidden>
- Date: Tue, 12 Dec 2006 08:02:53 -0800 (PST)
Bindings are a somewhat advanced subject that usually looks like magic (even though its not) to folks just learning the basic framework operation. Nevertheless, if you are comfortable...
You can use Cocoa bindings with any data type including a regular C array. You just need to provide the accessor methods required for any object to interact with bindings.
In your case you need to implement
@interface Stuff : NSObject {
...
int thing [ 150 ];
...
}
- (unsigned int)countOfThing;
- (NSNumber *)objectInThingAtIndex:( unsigned int)anIndex;
@end
@implementation Stuff
- (unsigned int)countOfThing
{
return 150;
}
- (NSNumber *)objectInThingAtIndex:( unsigned int)anIndex
{
NSAssert(anIndex < 150, @Index out of range);
return [NSNumber numberWithIntValue:thing[anIndex]];
}
@end
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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