views:

47

answers:

1

I am receiving the above warning in my code. I looked up the method in the documentation and found it was declared in UINibLoading.h. I tried importing this, but the warning didn't disappear.

+3  A: 

loadNibNamed:owner:options: is an instance method, as indicated by the leading - in the header file and in the documentation.

- (NSArray *)loadNibNamed:(NSString *)name owner:(id)owner options:(NSDictionary *)options

If this were

+ (NSArray *)loadNibNamed:(NSString *)name owner:(id)owner options:(NSDictionary *)options

that would have been a class method.

You need to first get the main bundle (i.e. the app bundle of the app you're developing) by the class method +mainBundle, and then apply loadNibNamed:owner:options:, as in

 [[NSBundle mainBundle] loadNibNamed:@"foo" owner:self options:nil];
Yuji
Thanks. So I didn't need to import that file at all
Casebash
Casebash: Were you coming from Cocoa? AppKit's `+[NSBundle loadNibNamed:owner:]` *is* a class method, unlike its UIKit counterpart.
Peter Hosey
I mainly do Cocoa (not Touch), and I didn't know `+[NSBundle loadNibNamed:owner:]` existed :p
Yuji