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 02-08-2011, 08:17 AM   #1 (permalink)
Registered Member
 
Join Date: Jan 2011
Posts: 8
Shake0615 is on a distinguished road
Default Using a XIB file or programming it

As a general rule of thumb, is it cheaper on memory and file size to create things programmatically or using XIB files? If so, how much memory would you save if you did it one way or the other?

For example, what's the difference in processing power/memory/file size to create a button through interface builder vs. coding it completely?

Thanks!
Shake0615 is offline   Reply With Quote
Old 02-08-2011, 08:24 AM   #2 (permalink)
Registered Member
 
Join Date: Mar 2010
Posts: 173
ranjit is on a distinguished road
Default

?

It all depends on how you create your objects in XCode. Nothing to do with your XIB. XIB is just to design the user interface.

If you use property(retain) for your objects, surely they are all being created and remains in memory right after the app is executed. But if you don't, and create them as needed, you should be okay.
ranjit is offline   Reply With Quote
Old 02-08-2011, 08:46 AM   #3 (permalink)
Registered Member
 
Join Date: Jan 2011
Posts: 8
Shake0615 is on a distinguished road
Default

Quote:
Originally Posted by ranjit View Post
?

It all depends on how you create your objects in XCode. Nothing to do with your XIB. XIB is just to design the user interface.

If you use property(retain) for your objects, surely they are all being created and remains in memory right after the app is executed. But if you don't, and create them as needed, you should be okay.
Well, I'm not familiar with how XIBs work. But I figured it would cost more memory to create and store the information about a button in a XIB file (I imagine it keeps all the objects in memory from beginning to end) as opposed to creating it in Xcode using NSButton and cleaning it up once I'm done with it.

If there is a difference between the two methods, I was hoping to know how marked that difference was. If there isn't, then I guess my question is pointless lol.
Shake0615 is offline   Reply With Quote
Old 02-08-2011, 05:02 PM   #4 (permalink)
Registered Member
 
jlehr's Avatar
 
Join Date: Aug 2009
Location: Reston, VA
Posts: 61
jlehr is on a distinguished road
Default

Quote:
Originally Posted by Shake0615 View Post
Well, I'm not familiar with how XIBs work. But I figured it would cost more memory to create and store the information about a button in a XIB file (I imagine it keeps all the objects in memory from beginning to end) as opposed to creating it in Xcode using NSButton and cleaning it up once I'm done with it.

If there is a difference between the two methods, I was hoping to know how marked that difference was. If there isn't, then I guess my question is pointless lol.
Nib files aren't stored in memory; they're files, so they're stored in the filesystem. Applications load nib files at runtime as needed by unarchiving their contents, which causes the objects to be allocated dynamically, just as they would if you were creating them programmatically.

The difference is that the objects loaded from a nib file already have some or all of the properties set, which in some cases can save writing and maintaining a fair amount of relatively boring code. Once the objects are in memory they're the same as any other objects, and their lifetimes will be determined by what your code does, just as with objects you allocate in code. There should be no difference in memory consumption.
__________________
Jonathan Lehr
About Objects - iPhone Developer Training
Web - http://www.aboutobjects.com
Blog - http://jonathanlehr.wordpress.com
Twitter - http://twitter.com/jlehr
jlehr is offline   Reply With Quote
Reply

Bookmarks

Tags
file size, interface builder, memory, programming

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: 371
13 members and 358 guests
blasterbr, Clouds, dre, EvilElf, jeroenkeij, jimmyon122, Mah6447, Morrisone, n00b, pungs, Sami Gh, stanny, toon4413
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,667
Threads: 94,121
Posts: 402,900
Top Poster: BrianSlick (7,990)
Welcome to our newest member, host number one
Powered by vBadvanced CMPS v3.1.0

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