views:

270

answers:

2

I have a XIB file with a UITextView, which I'm associating with a UITextView* outlet in my controller:

@interface MyController : UIViewController <UITextViewDelegate> {
    IBOutlet UITextView *textView;
}

@property (nonatomic, retain)  IBOutlet UITextView *textView;

I've aded the prototype in desperation, I've not implemented any of the methods of the delegate.

My view is loaded from a tab bar defined in my main XIB file. When I tap on the relevant tab bar button, an exception is thrown immediately (before any controller methods are called). The top of the call stack looks like this (from the debugger):

#0  0x93829bc6 in -[NSException raise]
#1  0x9157f8f8 in _NSSetUsingKeyValueSetter
#2  0x9157f35e in -[NSObject(NSKeyValueCoding) setValue:forKey:]
#3  0x91603f81 in -[NSObject(NSKeyValueCoding) setValue:forKeyPath:]
#4  0x30c1fadb in -[UIRuntimeOutletConnection connect]
#5  0x9381ebe5 in -[NSArray makeObjectsPerformSelector:]
#6  0x30c1e629 in -[UINib instantiateWithOptions:owner:loadingResourcesFromBundle:]
#7  0x30c2068c in -[NSBundle(NSBundleAdditions) loadNibNamed:owner:options:]
#8  0x30ac6f26 in -[UIViewController _loadViewFromNibNamed:bundle:]

It appears that there's some problem setting the text view outlet. I'm sure it's related to the UITextView because if I comment out the text view related code and remove the text view from the XIB, the view loads fine. There's no error message available on the console.

Are there any special considerations with UITextView elements when created in IB? I've got it connected to the IBOutlet in my code and the delegate is set to the 'Files Owner' (I've also tried it without a delegate).

+1  A: 

In your tab view, did you set the owning class to MyController for the tab where you've set your XIB? If you don't do this, you'll get this kind of selector setup error. Pulled my hair out a bit over this one.

Chaos
Right on the money! Thanks.That's another evening written off thanks to IB.
edoloughlin
A: 

Hi,

Go into Interface Builder and select your instance of MyController. Click the second tab in the info panel to show all the connections attached to the object. It should show the existing "tableView" outlet and a few others. If it's grayed out - it means Interface Builder's definition of the connection is incorrect and the outlet is invalid. If that's the case (as I think is will be?) just break that connection by clicking the X and create it again. I've had this happen a couple times when I update the names of outlets and actions in XCode.

I'd also try leaving the delegate unset to make sure that's not the problem. I don't think that should matter though.

Good luck!

Ben Gotow