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

Sergio10

macrumors regular
Original poster
Oct 3, 2007
137
0
Hello,

I need to get from the myxib.xib view/views controls and use it in the AppDelegate.m

So I use:
PHP:
NSArray *xib = [[NSBundle mainBundle] loadNibNamed:@"myxib" owner:self options:nil];

BUT it crashes(( I attached current simple project: http://www.mediafire.com/download.php?zwam3enynm2

Please help me. What is wrong?

Thank you.
 

wlh99

macrumors 6502
Feb 7, 2008
272
0
Hello,

I need to get from the myxib.xib view/views controls and use it in the AppDelegate.m

So I use:
PHP:
NSArray *xib = [[NSBundle mainBundle] loadNibNamed:@"myxib" owner:self options:nil];

BUT it crashes(( I attached current simple project: http://www.mediafire.com/download.php?zwam3enynm2

Please help me. What is wrong?

Thank you.

You are trying to assign an NSBundle to an NSArray, and loadNibNamed isn't a method NSBundle knows. Look at the API docs for those classes. Also look at NSViewController

Code:
NSViewController viewController = [[NSViewController alloc] initWithNibName:@"view" bundle:[NSBundle mainBundle]];
 

dejo

Moderator emeritus
Sep 2, 2004
15,982
452
The Centennial State
Please help me. What is wrong?
As wlh99 said, you are trying to call a method on an instance that does not have an instance method of that name. That's never going to work. Based on this and a number of other recent threads of yours, Sergio10, I think you might want to step back from the real coding for a while, go (re)learn the basics of Objective-C and iPhone development, and come back when you are much more comfortable with those.
 

Sergio10

macrumors regular
Original poster
Oct 3, 2007
137
0
Thanks for:
PHP:
NSViewController viewController = [[NSViewController alloc] initWithNibName:@"view" bundle:[NSBundle mainBundle]];
It's works.
BUT:
1. what to do when I have two UIView in the bundle(XIB)? How to load the view exactly I need?
2. Is it possible to avoid of saving controller file(MyController.m) for file's Owner? Because I transfer view only.

Thank you
 

wlh99

macrumors 6502
Feb 7, 2008
272
0
1. The line I gave you creates a view controler and loads the nib. You don't load part of the nib. To do anything with it (like display a view) requires more code and varys depending on what you are doing. It might be one line, and might be several lines and need more controllers.

2. I don't understand this question. By the way you ask it seems like you really need some fundementals. Any nib file has an owner, the object that loads it. In this case the owner is viewController because the view controller loaded the nib with initWithNibName: The file owner in IB is how Outlets and Actions are created and how viewController "talks" to individual objects in the nib.

I hope I don't sound rude, but the fastest way to learn this is with some books. Given 1 month per book you would be in good shape in three months. Otherwise you would be asking more and more questions and in 3 months only be more confused.

http://www.amazon.com/Programming-Objective-C-Stephen-Kochan/dp/0672325861

http://www.amazon.com/Cocoa-Programming-Mac-OS-3rd/dp/0321503619/ref=pd_sim_dbs_b_4

http://www.amazon.com/Beginning-iPhone-Development-Exploring-BEGINNING/dp/B001TM92AW/ref=sr_1_1?ie=UTF8&qid=1252617701&sr=1-1
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.