Re: Large over 100K pixel high ruler scroll view
Re: Large over 100K pixel high ruler scroll view
- Subject: Re: Large over 100K pixel high ruler scroll view
- From: Jens Alfke <email@hidden>
- Date: Tue, 30 Aug 2011 20:59:49 -0700
On Aug 30, 2011, at 8:43 PM, Julie Porter wrote:
> NSLog(@"have %lu events.",[[MyDocument CISEvents] count]);
>
> I get the error:
> 'MyDocument' may not respond to '+CISEvents'
This is the distinction between a class and an object. A class is a kind of template that defines what data objects contain. It doesn’t make any sense to use [MyDocument CISEvents]; it’s like asking “how many spots does the word Leopard have?”. Properties apply to individual objects, not to classes. This is pretty fundamental, and a lot of other things in Cocoa programming (as with Java or many other languages) won’t make sense until you’ve got it down.
I think the other thing you’re having trouble with is how to have the different objects (not classes) in your app refer to each other. A pretty common way to do this is for the controller object (the document in your case) to initialize the view right after it loads by telling it where the model object is. In your case I’m assuming the array of events is the data model.
So one solution is to give your view class a settable property that’s also an array of events, and have the document set that property on the view after the window loads. Typically you’d give the document class an IBOutlet pointing to the view, and wire that up in IB. Then as soon as the nib loads, the document knows the view and can initialize it.
—Jens_______________________________________________
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