Re: Bindings using other collections?
Re: Bindings using other collections?
- Subject: Re: Bindings using other collections?
- From: Robert La Ferla <email@hidden>
- Date: Sun, 08 Feb 2004 21:27:55 -0500
Yeah but with that approach, I have to wrap every array in the model.
As far as I know, Java doesn't have "pose as" functionality. If I have
a simplistic data source, the wrapper approach works but otherwise, it's
a big effort.
Also, how do you programmatically set up bindings in Java? I can do it
in Objective C but the documentation for Java is lacking or perhaps the
Java implementation isn't complete in Panther. Has anyone done this
successfully?
mmalcolm crawford wrote:
On Feb 8, 2004, at 7:43 AM, Robert La Ferla wrote:
It appears that the new bindings architecture is largely (but not
entirely) dependent on Objective C. Is it possible to bind to Java
collections instead of NSMutableArray for relationships? If so,
how? e.g. If I have a Company that has many Employee objects, how
can I use a Vector or ArrayList for the to-many employees
relationship so that the bindings system knows how to add, remove,
get, etc... from that collection?
<http://developer.apple.com/documentation/Cocoa/Conceptual/
KeyValueCoding/Concepts/AccessorConventions.html>
and
<http://homepage.mac.com/mmalc/CocoaExamples/controllers.html>
The array controller uses key-value coding to retrieve values. If
your data source implements the relevant indexed accessors, it
doesn't matter what the data model is behind them. For example, you
could have a raw bitmap. If you call the variable "bitmap", then
provided you implement
- (unsigned int)countOfBitmap;
- (id)objectInBitmapAtIndex:(unsigned int)index;
and if you want to edit it:
- (void)insertObject:(id)anObject inBitmapAtIndex:(unsigned int)index;
- (void)removeObjectFromBitmapAtIndex:(unsigned int)index;
(and optionally for efficiency:
- (void)replaceObjectInBitmapAtIndex:(unsigned int)index
withObject:(id)anObject;
)
then the actual implementation details are irrelevant.
mmalc
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.