Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Hello World

Hello World
Thread Tools
Fresh-Faced Recruit
Join Date: Feb 2001
Location: Sweden
Status: Offline
Reply With Quote
Feb 19, 2001, 07:51 AM
 
Could someone post a Cocoa "Hello World", that brings up a window, the menubar, some buttons and maybe some static text, without using Interface Builder.
It would be even cooler if it includes the way you initalize and display an NSOpenGLView too, without IB, of course.

It would be very useful. :-)

/Joel Edström
     
Senior User
Join Date: Nov 2000
Status: Offline
Reply With Quote
Feb 19, 2001, 11:43 AM
 
Just curious...why?

Why would you want to drop IB and do it all by hand?
     
Admin Emeritus
Join Date: Oct 2000
Location: Boston, MA
Status: Offline
Reply With Quote
Feb 19, 2001, 04:34 PM
 
Just go to Google.com and type in all the classes you want to use.

It'll show you results from Apple first. From these, it's easy to find out how do initialize and display windows, views, &c. &c.

Really, it is a waste of time though. Use IB. IB rocks.

[This message has been edited by parallax (edited 02-19-2001).]
"Against stupidity, the gods themselves contend in vain" (Schiller)
     
Senior User
Join Date: Nov 2000
Status: Offline
Reply With Quote
Feb 19, 2001, 05:15 PM
 
The only reason I could come up with for wanting to do an IB-less Cocoa app is to make it GUI-hacker unfriendly.

Even then there's ways to still use IB and make it nearly impossible to hack the GUI without breaking the application. Like, drop everything onto your windows, create the outlets and resize and place in code, for instance. I think OmniWeb does(did?) this to a certain extent with a few of their UI elements. It's not that uncommon, anyway.

Well, still curious.
     
Forum Regular
Join Date: Oct 2000
Location: Portland, OR USA
Status: Offline
Reply With Quote
Feb 19, 2001, 06:29 PM
 
I think that the most likely reason to want to know how to create GUI elements without IB, othre than intellectual curiosity, is for the creating of dynamic interfaces where the elements aren't known until runtime.
     
Senior User
Join Date: Nov 2000
Status: Offline
Reply With Quote
Feb 19, 2001, 08:16 PM
 
Okay, there's another reason. I guess I hadn't thought of that (yet).

Even still you could do some of that with IB. Instead of starting all from scratch you could subclass NSObject (or whatever is appropriate), get your menu bar and an initial window(or not) in IB and then create the rest manually. That would give you starting point with little coding effort.

You can still create things by hand after that but I guess we're not going for The Easy Way Out(tm).
     
Mac Enthusiast
Join Date: Feb 2000
Location: Storrs,Connecticut, USA
Status: Offline
Reply With Quote
Feb 20, 2001, 05:55 AM
 
One reason to create windows programmatically is if it isn't used much and you don't want it to be loaded every time you launch the program. Why waste the memory? I create lots of sheets programmatically, but I do it the easy way with the functions in AppKit. I haven't had a good reason to create a window programmatically. Usually I have lots of stuff in it so I just save the window in it's own nib and load that everytime. that way it's easy to have lots of instances of it.
     
   
Thread Tools
Forum Links
Forum 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
Top
Privacy Policy
All times are GMT -5. The time now is 12:25 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2