Re: Customizing UIPageViewController during init
Re: Customizing UIPageViewController during init
- Subject: Re: Customizing UIPageViewController during init
- From: Quincey Morris <email@hidden>
- Date: Wed, 24 May 2017 10:22:02 -0700
On May 24, 2017, at 08:17 , Steve Mills <email@hidden> wrote:
>
> Is it wrong to call two different init methods?
Yes, I think you have to regard it as wrong. Apart from hidden weird behavior, it risks memory management problems, because init methods generally (should) refer to instance variables, not properties, and init code will generally assume that all instance variables are nil or 0.
What you can theoretically do is allocate *another* instance of UIPageViewController, initialize with the other init method, and return that instance instead of the “self” you started with. However, it’s not obvious that you can do this during unarchiving, because the unarchiver may have already recorded the “self” pointer that was passed in. Maybe that’s OK, I don’t know.
Alternatively, you could use the delegate method “unarchiver:didDecodeObject:” to replace the unarchived object with another instance that you initialized yourself.
_______________________________________________
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