|Mar 25, 2009, 09:53 AM||#1|
Instantiation of objects in IB
I'm trying to achieve loading of custom views from nib files.
I have a nib which contains NSView with some controls on it, custom object of class B which was loaded through classes tab and subsequently instantiated. And a filesOwner set to my custom class A. Class A contains a references to NSView and B and I bind this A's outlets in IB to appropriate objects.
Class A has a method to load itself from nib using loadNibNamed:owner: from NSBundle.
The methods returns true which means nib was loaded successfully, but when I try to look at the fields I see that reference to NSView is populated (and I actually use it inside a form to show contents), but the reference to B is always nil.
I've also tried to stick NSObjectController and add another field to A to check if it is a matter of custom class being instantiated, but the result is the same.
Only the NSView instance is created and referenced by fileOwner.
I suggest that B's instance is never created since its init method is never called according to logging and breakpoints.
I think it is quite trivial operation that I'm doing, so I should be missing something in details or conceptually.
|Mar 25, 2009, 01:57 PM||#3|
Exactly. I tried to add initWithCoder: to the custom object but it doesn't seem to change anything.
I was thinking that loadNibNamed: might be a wrong method to inflate the nib back.
|Mar 25, 2009, 02:00 PM||#4|
If you're on 10.5 I'd suggest using NSViewController as it will make your life easier.
But I'm not sure what else to say. Can you post a screenshot of your nib? Maybe it's configured incorrectly.
|Mar 25, 2009, 02:03 PM||#5|
Nop I'm on 10.4 so I don't have NSViewController. And I also want to know what is actually happening under the hood. :)
I'll try to post a screenshot and a code snippet when I'm back home though.
|Mar 26, 2009, 05:21 AM||#7|
Problem is resolved. It turned out really a schoolboy thing.
I renamed nib file at some point in past and forgot to change the name used to load it.
Xcode kept compiled resource somewhere and it was successfully loaded, but it didn't contained appropriate objects.
Once I made clean and build it started to fail when loading nib since stale files were removed by clean.
Once I fixed the nib name in code everything started to work smoothly.
Thanks for the replies, they showed me the right way.
|Thread Tools||Search this Thread|
|thread||Thread Starter||Forum||Replies||Last Post|
|lazy instantiation||grandM||iPhone/iPad Programming||4||Apr 28, 2014 12:35 PM|
|Objects in Objective C||luke71933||Mac Programming||6||Apr 8, 2014 09:20 AM|
|OpenGL ES: Vertex Buffer Objects and Vertex Array Objects||Blakeasd||iPhone/iPad Programming||2||Jul 13, 2013 12:24 AM|
|Desktop objects removed ?||Mellthorn||Mac Basics and Help||6||Nov 28, 2012 02:18 PM|
|LR -> PS as smart objects||patent10021||Digital Photography||1||Oct 17, 2012 04:44 PM|
All times are GMT -5. The time now is 12:21 AM.