On 06/10/2009, at 3:00 PM, Dragos Ionel wrote:

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.

How can this be achieved?


Many different ways.

One possibility is to define an informal protocol that your chapter and book controllers agree upon, such that when the chapter has finished, it calls the book controller with something like - chapterDidFinish: at which point the book controller can set up the next chapter. If chapters are owned by books it it the responsibility of the book to release the chapter - it should not typically release itself.

How does the chapter know which book it belongs to? Easy - it keeps a reference (non-retained) to it which the book sets whenever it initialises a chapter.

Essentially what you have here is a straightforward tree structure, with book at the root, chapter as the next level of nodes and pages as the next level. Any tree-management approach will work here.

--Graham


_______________________________________________

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