Newbie: how to use custom views
Newbie: how to use custom views
- Subject: Newbie: how to use custom views
- From: email@hidden
- Date: Sat, 10 Nov 2001 20:01:18 +0100
Hi,
this is yet another newbie question, so please be patient.
I have some background on how to do things in Java and Swing and want to
implement my first Cocoa app (temp converter does not count), now I am
trying to find out how some paradigms used in Swing map to Cocoa.
The task:
Imagine a view (container) that renders it's contents based on some kind
of "model". The model is basically an ordered collection of items.
Depending on the type of each item a specialized view is created and
added to the container view.
(In Swing you could implement this using a JList and a custom
ListCellRenderer.)
The problem:
I started to design the various item views in Interface Builder by
subclassing NSView. Next I wanted to visually compose the custom view
classes, but I found no way to do this without instantiating them. So I
created "prototype" instances for each view class and customized them by
adding images, text labels etc.
Now I am stuck. When rendering the model I need to create views based on
these prototype instances that were composed in IB (and stored in the
NIB file I suppose). How do I achieve this ?
Maybe I got it all wrong ?