Re: Graphing data from NSArrayController
Re: Graphing data from NSArrayController
- Subject: Re: Graphing data from NSArrayController
- From: "I. Savant" <email@hidden>
- Date: Sat, 9 Feb 2008 10:38:44 -0500
The basic premise is that I want to graph data from an NSTableView.
Here's what I have in place so far.
Here is one problem in your line of thinking. Read this page:
http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaFundamentals/CocoaDesignPatterns/chapter_5_section_4.html
... your goal is to get at the model layer via your controller
layer, so you can draw things in your view layer.
I guess what I'm just not figuring out is how to get the data from
my NSArrayController (or NSTableView... I don't know which of those
to be using... maybe either works?) to my graphing object.
See above. You definitely want the controller. As to how to get at
it, read this:
http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaFundamentals/CommunicatingWithObjects/chapter_6_section_1.html#
I just want to update the graph any time that the user adds/edits/
deletes the data in the NSTableView. It seems like it would be so
simple, but I'm missing something.
If your data is managed by an array controller, you will need to
understand the basics of the technologies on which Cocoa Bindings rely
(Key Value Coding / Key Value Observing: http://developer.apple.com/documentation/Cocoa/Conceptual/KeyValueCoding/Concepts/BasicPrinciples.html
and http://developer.apple.com/documentation/Cocoa/Conceptual/KeyValueObserving/KeyValueObserving.html
respectively)
You'll want to bind the appropriate attribute(s) of your view to
your array controller's arranged objects (or a keypath of those
objects).
I added an the following code to the header of my NSObjectController
class...
IBOutlet NSManagedObjectContext *myMOC;
But I couldn't seem to access the data from the TableView.
I'm not sure what led you to believe that would behave the way you
expected, but no, that won't solve your problem.
I don't know how to set up the code or the IB to pass data from one
object to another.
http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaFundamentals/CommunicatingWithObjects/chapter_6_section_1.html
Second, I don't know how to detect the event that the data in the
Table View has changed (thus triggering the previous sentence).
It depends on several factors, but your main issue is that you
haven't yet grasped the fundamentals of Cocoa's design patterns and
are trying to use the more advanced technologies (Cocoa Bindings).
I strongly urge you to put this on hold for a week or so and spend
time reading (and re-reading) this entire guide (to which the pages
above belong):
http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaFundamentals/Introduction/chapter_1_section_1.html
When you're done with that guide, read this one:
http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaBindings/CocoaBindings.html
I hope this helps.
--
I.S.
_______________________________________________
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