Re: self release
Re: self release
- Subject: Re: self release
- From: Jeremy Pereira <email@hidden>
- Date: Tue, 6 Oct 2009 12:03:58 +0100
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 (email@hidden)
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:
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden
References: | |
| >self release (From: Dragos Ionel <email@hidden>) |