Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 08-12-2010, 11:24 PM   #1 (permalink)
Registered Member
 
Join Date: Aug 2010
Posts: 36
chicagosky is on a distinguished road
Question Newbie Alert: Basic question on development

Hello All

I am a newbie to iPhone and Objective-C development but have over 12 years of C & Java development experience. Strange, but I am finding Objective-C very difficult to switch over to, the method signatures are just unconventional for me and the new terminology as well. Anyway, I digress..

I have a few basic questions that I am hoping someone can help me understand. I've read a couple of books on this topic but none of them clarify adequately

1. What is a XIB and NIB file - the books refer to them as being the core files but what do they stand for and what is their exact purpose in a project?

2. I understand the delegation and MVC patterns but what I do not understand is the execution order? For instance, in a Java project the first file invoked is the file containing the main method and then various objects etc. are instantiated and if it is a server side application then you have EJBs etc which are invoked and ready for calls. What exactly goes on with an iPhone project? Is there a diagrammatic representation of the invocation order? I am very confused by the various delegates and objects and controllers etc.

3. What is the difference between a View based application template and a window based application template? When would you use either of these?

These are my burning questions for now - thanks for any and all help in advance. If I posted in the wrong forum, please let me know.

Thanks
ChicagoSky
chicagosky is offline   Reply With Quote
Old 08-12-2010, 11:37 PM   #2 (permalink)
Registered Member
 
Join Date: May 2010
Posts: 577
Speed is on a distinguished road
Default

Quote:
1. What is a XIB and NIB file - the books refer to them as being the core files but what do they stand for and what is their exact purpose in a project?
From my experience, a .xib file is just a .nib but in development. .nib's hold all of the display data for your application. You can open up a .xib in interface builder and build what your application will show graphically.

Quote:
2. I understand the delegation and MVC patterns but what I do not understand is the execution order? For instance, in a Java project the first file invoked is the file containing the main method and then various objects etc. are instantiated and if it is a server side application then you have EJBs etc which are invoked and ready for calls. What exactly goes on with an iPhone project? Is there a diagrammatic representation of the invocation order? I am very confused by the various delegates and objects and controllers etc.
There are various object delegates so you can get more from an object that you place. For example, you are limited to some things with a regular UIWebView but as soon as your RootViewController becomes a delegate for that UIWebView, you can receive data about what it is doing. Your applications will generally start with the MainWindow.xib which links to the RootViewController.xib. Your AppDelegate will run code upon startup and then your RootViewController classes will take over. To adjust something at a view subclass does on startup, you will use the ViewDidLoad or ViewWillAppear methods. In the ViewDidLoad, you can start your timers and other variables. Unlike Java (I think), you will have to declare everything in your .h (header) file and use it in your .m (implementation) file. For example, if I had an integer, I would first add this in my .h:

Code:
int myInteger;
Now, I can use it in my .m:

Code:
myInteger = myInteger + 5;
When you create a new .xib, you have the option to have a viewController come with it. In this viewController, you can create methods and actions for that .xib. Essentially, it controls the view.

Quote:
3. What is the difference between a View based application template and a window based application template? When would you use either of these?
Personally, I use a View Based application as it comes with everything that you need to get started. A Window Based application (to my knowledge) is a stripped down version of a View Based application. Personally, I will use Navigation Templates and just remove the TableView. I have the navigation controller already built in (so I can move .xibs and have multiple views) and I will also have the exact same setup as a view based application.

Last edited by Speed; 08-12-2010 at 11:40 PM.
Speed is offline   Reply With Quote
Old 08-12-2010, 11:51 PM   #3 (permalink)
Registered Member
 
Join Date: Aug 2010
Posts: 36
chicagosky is on a distinguished road
Default

Thanks Speed. A few follow on questions to your reply, if I may

1. What exactly is the full form of XIB and NIB? Where do I find the NIB file? I can find the XIB files but can't locate the NIB files

2. If I were to create a multi-screen iPhone application, for instance something like the phone book application would a view based application template enable me to do that? Or should I use a window based application template?

Thanks again for your help
chicagosky is offline   Reply With Quote
Old 08-12-2010, 11:51 PM   #4 (permalink)
Registered Member
 
Join Date: Apr 2010
Posts: 651
kapps11 is on a distinguished road
Default

ok here we go:

About xibs:
xibs/nibs are files that apple uses in its program called interface builder. They are essentially archives of various UI elements in your app that IB opens so you can edit your UI grapihcally, and they are also generally used in the templates to organize the starting of your app, which leads to the next question:

Execution order:
Your app will have a delegate, called MyAppDelegate or whatever. it gets function calls when your app is launched, closed, backgrounded, etc, and that is really where your app starts. From there, the general procedure is to create view controllers and add them to the main window (which the templates usually do for you) and the view controllers are where the main part of your coding will be done. Xibs fit into this because apple uses them to set the delegate property of UIApplication to your app delegate, and that is why the get the AppLaunched calls and everything. That is probably why your book said theyre the main part or whatever.

Window vs View Based application:
View based application template provides you with a starting view controller and xib to match, while window based app is literally your cut down dry app with nothing but the delegate.


Hope that helps!
kapps11 is offline   Reply With Quote
Old 08-12-2010, 11:58 PM   #5 (permalink)
Registered Member
 
Join Date: Jul 2010
Location: Seattle, WA
Posts: 46
C6Silver is on a distinguished road
Default

I may suggest the following books (one or both).

Beginning iPhone 3 Development by Dave Mark and Jeff LeMarche and/or iPhone Application Development for Dummies by Neal Goldstein.

The latter book does a tremendous amount of hand holding at the beginning which will likely answer the questions you are asking. The former does a little less hand holding, but goes into far greater detail and depth as the chapters progress. What is covered by page 30 of the former isn't covered until probably page 130 of the latter.

You did mention you read some books, but I am not sure which ones. You could also sit in the bookstore for an hour or so and read the beginning of the Goldstein book which will probably clear up a lot of the initial confusion you are experiencing.
C6Silver is offline   Reply With Quote
Old 08-13-2010, 01:03 AM   #6 (permalink)
Registered Member
 
Join Date: May 2010
Posts: 577
Speed is on a distinguished road
Default

Quote:
1. What exactly is the full form of XIB and NIB? Where do I find the NIB file? I can find the XIB files but can't locate the NIB files
You will be able to find your .xibs in the resources folder in XCode. The .nibs are created at build-time so you will not be able to find them in your project. Just edit your .xib and your .nib will follow through accordingly.

Quote:
2. If I were to create a multi-screen iPhone application, for instance something like the phone book application would a view based application template enable me to do that? Or should I use a window based application template?
To create a multi-screen iPhone application, I would use a navigation template but just strip it down. To strip it down, you can do the following:

1) Open up RootViewController.xib.
2) Delete TableView.
3) In your Library, find View and double click it to add it in.
4) Right click on File's Owner (this is the link to your viewController with methods and outlets) and drag View to your View that you added before. You should see a blue line that stretches, drag this blue line over to the view that you added to connect it. You should then see (View - View) when you do it correctly.
5) Press Apple-S and Apple-Q to save and quit Interface Builder.
6) Go to RootViewController.h and change TableViewController to ViewController (it is in the top by the @ line).
7) Open RootViewController.m and delete everything past @implimentation RootViewController; and do not delete the following:

Code:
- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Relinquish ownership any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
    // Relinquish ownership of anything that can be recreated in viewDidLoad or on demand.
    // For example: self.myOutlet = nil;
}


- (void)dealloc {
    [super dealloc];
}


@end
8) Now, you should be good to go. If you want to hide the navigation bar, you can do the following:

9 a) Open up YourAppDelegate.m.
b) Go to ApplicationDidFinishLaunching and add the following line:

Code:
[self.navigationController setNavigationBarHidden:YES];
So, with the following above, you can create a view application with a navigation controller built in, very easily. From here, you can push view controllers by adding just 3 lines of code.
Speed is offline   Reply With Quote
Old 08-13-2010, 12:33 PM   #7 (permalink)
Registered Member
 
Join Date: Aug 2010
Posts: 36
chicagosky is on a distinguished road
Default

Thanks to all - your suggestions helped. I also took the suggestion to get the "..for dummies" book and it seems to help immensely over the other two books I have (iPhone SDK Programming - James Brannan & Programming Objective C 2.0 - Stephen Kochan). It also answered one my earlier questions

A "nib" extension stands for NeXT interface builder and is basically a legacy terminology ever since interface builder was launched for Mac OS X - which is when these files were renamed as "xib".
chicagosky is offline   Reply With Quote
Reply

Bookmarks

Tags
beginner, newbie

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 350
5 members and 345 guests
bignoggins, Chickenrig, givensur, linkmx, PlutoPrime
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,657
Threads: 94,118
Posts: 402,894
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jenniead38
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 12:44 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0