> 
> None of use who have weighed into this thread have an explanation (yet) of 
> why that is. We expect the NIB-loading machinery to produce an invocation of 
> initWithFrame:, but it apparently isn’t. I just looked at the documentation 
> again:
> 
>       
> https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/LoadingResources/CocoaNibs/CocoaNibs.html
>  
> <https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/LoadingResources/CocoaNibs/CocoaNibs.html>
> 
> and I notice it says this (edited down a bit):

I now know why it does this, it’s another unexpected, undocumented, 
not-in-the-release-notes-as-far-as-I-can-find-even-searching-for-it feature of 
Xcode 6. If you click on the xib/nib file and look at its inspector 
information, just below the bit about using autolayout is a section called 
‘runtime behavior’ and under that is ‘Instantiation: Prefer coder’ which for me 
was checked on by default in a new project. if you toggle that on and off 
you’ll get initWithCoder: when on and initWithFrame: when off. 

Nice that someone finally fixed this inconsistency in which method gets called, 
nicer would be if there were comprehensive release notes which tell you stuff 
like this or an updated NIB loading guide.

This is why I’ve adopted the pattern I referenced earlier in the thread for 
funnelling all my init* methods as much as possible through one piece of code, 
especially for NS/UIView subclasses. Then it doesn’t matter when I add them by 
hand with init, or initWithFrame: or they fall out of a NIB or storyboard 
(storyboards don’t have the checkbox so I have no idea what you get there, 
probably initWithCoder:) the code gets called. 


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/xcode-users/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to