On 6 Oct 2009, at 05:00, Dragos Ionel wrote:

I have the following scenario:
A UIViewController, called BookViewController represents a book.

Another UIViewController, ChapterViewController, represents a chapter in the
book.

BookViewController initializes and displays one ChapterViewController, that
represents the current chapter that is read.

The user moves through the pages of the chapter, back and forth. This
functionality belongs to ChapterViewController.

When the last page of the chapter is reached and the user tries to get to the next page, the code inside the ChapterViewController has somehow to tell the parent controller, BookViewController that it needs to be released and
another chapter to be initialized.

The short answer is to maintain a weak reference (i.e. non retained) to the BookViewController in the ChapterViewController and send a message to it when the chapter is finished.

However, you might consider separating the model and the controllers a bit more explicitly. I would have a Book object which contains an ordered collection of Chapter objects as the model. The ChapterViewController would have a reference to the book object and the chapter object it is currently displaying. When the reader gets to the end of a chapter, the ChapterViewController would request the next chapter from the Book object and redisplay its view with the new chapter.



How can this be achieved?

Your help is appreciated.
Dragos
_______________________________________________

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/adc%40jeremyp.net

This email sent to a...@jeremyp.net

_______________________________________________

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