New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Advice and insight from world-class Apple enthusiasts Exclusive access to members-only contests, giveaways and deals

Join today!

 
Start a Discussion
 

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
OS X - Development and Darwin Discussion and questions about development for Mac OS X.

Cocoa document based app.


Post Reply New Thread Subscribe

 
Thread Tools
nglie

 
Member Since: Apr 21, 2010
Posts: 1
nglie is on a distinguished road

nglie is offline
I am creating a document based cocoa app. Each document needs to reference a central object to retrieve some of its data. I have all the Documents working and displaying nicely, but where do I create the central object?

I suppose I need to create some kind of delegate of the Application? But I'm completely lost how to do that. Any offers?
QUOTE Thanks
xstep

 
xstep's Avatar
 
Member Since: Jun 25, 2005
Location: On the road
Posts: 3,231
xstep is a name known to allxstep is a name known to allxstep is a name known to allxstep is a name known to allxstep is a name known to allxstep is a name known to allxstep is a name known to all
Mac Specs: 2011 MBP, i7, 16GB RAM, MBP 2.16Ghz Core Duo, 2GB ram, Dual 867Mhz MDD, 1.75GB ram, ATI 9800 Pro vid

xstep is offline
Might depend on what you are doing, but the common case is user preferences and defaults. Look for samples that use NSUserDefaults.

I'm still grasping much of this too, but...

You would create a delegate object for your application (ofter referred to in samples as AppController), and instantiate that in IB and set it as the "File's Owner" delegate. In this object you you create your special object upon startup. You could then get to it by
Code:
[[NSApp delegate] myCustomerGlobalObjectNameiVar]
NSApp is a global variable that points to your applications instance of NSApplication.

Do not retain or release that object in your documents. They don't own it. You can assign it to a local variable if you want.

You may think it a good idea to use the delegate as your object, but the delegate can be responsible for many things and is capable of responding to many optional delegated methods from the NSApp instance. It is a general purpose object that helps you control your application.

CameraTime - Time lapse photography for novice and advanced users.

When asking questions, post the version of your software. You'll receive better answers.

Please post your results to the thread as it is good feedback.
QUOTE Thanks

Post Reply New Thread Subscribe


« Shoutcast installation in linux | Programing Language »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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 Off
Forum Jump

Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
MobileMe eMail crashes the iPhone Mail app Papaspyropoulos iOS and Apps 20 10-29-2010 11:08 AM
Anyone use/familiar with Mendeley desktop research app bobross OS X - Apps and Games 0 09-12-2009 07:10 AM
App to control iTunes via Web Browser? Mr.Preston OS X - Apps and Games 2 07-13-2008 04:25 PM
Any cocoa developers for hire (project based)? giulio OS X - Development and Darwin 0 03-31-2008 04:55 PM
RDP Remote Desktop App? Horness Switcher Hangout 2 02-01-2008 06:34 AM

All times are GMT -4. The time now is 10:11 PM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?