Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

MihaiD

macrumors newbie
Original poster
Jan 12, 2009
5
0
I have a UIViewController subclass and a xib file who's owner is set to the former. Now I need to subclass the first UIViewController subclass to add some specific behavior. However when I try to push an instance of the UIViewControllers subclass-subclass on the UINavigationController my program stops.

Any ideea on what I could be doing wrong? Do I need different xib's for the two classes?

Thanks
 

Spike099

macrumors regular
Feb 18, 2007
143
0
Canada
Hey MihaiD,

You will need to create another XIB with the second subclass as the File's Owner.

Let's say you have subclass B which is a subclass of A. You instantiate an instance of A. In this scenario you have NO access to any methods or properties declared in B.

However, if you do it the other way around, you instantiate an instance of B, then you have access to everything in B and A(unless you make stuff private...). Make sense?

So, maybe you want your file's owner in the first xib to be subclass B?
 

caveman_uk

Guest
Feb 17, 2003
2,390
1
Hitchin, Herts, UK
I don't think that's strictly correct. You should be able to use a xib that has as it's File's Owner the parent class, with a subclass so long as you don't have anything in that xib that refers to the subclass. I've done it and it does work.
 

Spike099

macrumors regular
Feb 18, 2007
143
0
Canada
I see what your saying. I think it is feasible as you initialize the file owner separately from the xib. What is the error your getting? Have you tried stepping through the process?
 

MihaiD

macrumors newbie
Original poster
Jan 12, 2009
5
0
@Spike099

I am not trying to refer to anything in the subclass' subclass. In fact that class is pretty much empty for now. What I'm getting is a NSInvalidArgumentException

@Luke Redpath

I'm not sure composition would help me. I'm trying to reuse most of the functionality from my first UIViewController subclass
 

MihaiD

macrumors newbie
Original poster
Jan 12, 2009
5
0
OK, found the problem. My superclass was relying on a certain member parameter being set and I forgot to do that. It all works now.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.