Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to handle Dropped Data



This is more of a best approach question as I already implement a solution it is just not really elegant (actually really kludgy).

I have a custom Cocoa photo view (which for imaging purposes looks like the main browsing window in iPhoto). The view has bindings enabled and from the binding it gets an array of file paths. In then takes those file paths and creates its own class (called PhotoViewObject), which contains thumbnail images, photo information, etc...

However, the original set of data comes from a MySQL database. The table associated with the photo data has its own class (called PhotoTableObject). On startup an array (called PhotoTableObjectArray) is populated with these PhotoTableObject objects which are bound to an array controller (called PhotoTableObjectArrayController) which is the controller from which the custom view used to get the photo paths. Specifically the custom view binds to the the arrangedObjects of PhotoTableObjectArrayController with the keypath photoPath.

My problem is, when I get a drop onto the custom view of an image I add the photo to the view. But I also want the database to be updated with the new photo. Right now the custom view has all the headers of the PhotoTableObject so that when we get a drop we create a new PhotoTableObject and add that to the array controller. But I don't think my custom view really should know about the PhotoTableObject class.

Unfortunately, I couldn't think of a better way of doing this. I guess what I need to do is sort of have a bidirectional communication. Right now when an object gets added to PhotoTableObjectArray, through bindings the information is sent to the custom view to update itself. But how can I have the opposite happen, when I add something to say the internal array of PhotoViewObject have the PhotoTableObjectArray get updated.

If I wasn't clear on my problems, please let me know. Any help is greatly appreciated!

Thanks.
---------------------------------------------------------------
Michael Petnuch
http://www.petnuch.com
email@hidden



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.