Re: MVC view/controller separation question
Re: MVC view/controller separation question
- Subject: Re: MVC view/controller separation question
- From: Keith Blount <email@hidden>
- Date: Mon, 4 Apr 2005 14:18:23 -0700 (PDT)
- Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys
Many thanks for the reply, greatly appreciated.
Now I'm really confused (I think I got lost somewhere
after the quartermaster shot the sergeant for making
tea... :) )
I would be really grateful if someone could tell me
the correct MVC set up given the following info:
Notes can be attached to ranges of text in a text
view. The text view draws selection rectangles around
all ranges associated with notes in
drawViewBackgroundInRect: A margin view may or may not
be associated with the text view. If it is there, it
draws the notes and has to keep track of their
positions so that they are always in sync with the
text view.
Given the great advice I've been given by everybody so
far, this is how I now see the setup - though there is
still some confusion:
KBNote - stores the note string and the NSRange of the
textView text with which it is associated; also knows
how to draw itself in a view (following Johnny
Deadman's advice).
KBNotesManager - manages an array of notes, adding and
removing them, and posting notifications of changes.
So far, so good. The problem comes with the following
two classes and how they should interact with the
notes manager:
KBNoteTrackingTextView - needs to draw selection
rectangles around ranges of text associated with
notes, and also needs to inform the notes manager of
changes to text so that the notes manager can update
the notes ranges accordingly (I'm still reluctant to
make the notes manager the delegate of the text view,
though, because I want to set the delegate elsewhere
for managing certain other aspects of the text view
that are specific to one application, while I want
this set of classes to be reusable).
KBMarginView - deals with drawing KBNotes. Needs to
track the notes manager for range changes so that it
can redraw the notes. Whenever the user clicks into a
note rectangle, a text view is created to edit the
string, so the margin needs to deal with changing
notes information and also adding and removing notes -
so again it needs to communicate with the notes
manager.
The main areas that now confuse me are:
1) Where should notes manager be created if not in the
text view? (NSTextView manages an attributed string,
why should the array of notes which are specific to
this text storage be any different?)
2) How should the margin view and text view tell the
notes manager to add and remove notes, or update their
ranges, if not directly calling on notes manager
methods (ordering it around, as John put it)? Sending
a notification to say that the notes manager should
add a note seems no better...
Again, sorry for the long post, but I would be really
thankful to anybody who can put me right here - it
seems that no matter which way I look at it, the view
needs to know about the controller...
Many thanks,
Keith
__________________________________
Yahoo! Messenger
Show us what our next emoticon should look like. Join the fun.
http://www.advision.webevents.yahoo.com/emoticontest
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden