On 8/29/11 7:29 PM, Graham Cox wrote:


Use Interface Builder to set up/design your interface.

Add a custom NSView, set its class to your subclass. Place it inside a standard 
NSScrollView. In the -awakeFromNib method of the custom NSView subclass, set 
the frame size to what you need. The standard NSScrollView will cope, you do 
not need to subclass NSScrollView (the scrollview doesn't display your content 
directly, it it is merely a container for another view that does display your 
content).

That's the essence of it. But in practice you'll probably want to have a 
NSDocument representing this file, in which case it is responsible for opening 
the file, working out the size and setting the view size as needed.
I already have the NSDocument.m which loads the array of dictionaries from the file. Do I place the awakefrom nib in that set of class files, or would they go into the file that I would derive from NSView called cisView.m?

Do I need to set up accessors between the myDocument and cisView class files or do they inherit from each other?

The custom NSView subclass is what is going to do the real work. In the -drawRect: 
method, which you're obliged to override, you are passed a "dirty rectangle". 
Using that rectangle, which is relative to the view's bounds, which in turn is the size 
of the total size you calculated from your file, you can work out what lines it is 
needing to redraw. Perform that calculation and request the data from the file. You'll 
need various lines of communication between your document and view (the document is the 
data model) which you can easily establish using outlets.
This is the part I already understand, but am unclear how to get to set up the init and awake overrides to get the 'dirty rectangle' I want. I think you have pointed me in the right direction.

-julie

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to