Results 1 to 2 of 2
Thread: Cocoa document based app.
-
04-22-2010, 01:14 AM #1
- Member Since
- Apr 21, 2010
- Posts
- 1
Cocoa document based app.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?
-
04-22-2010, 06:28 PM #2
- Member Since
- Jun 25, 2005
- Location
- On the road
- Posts
- 3,231
- Specs:
- 2011 MBP, i7, 16GB RAM, MBP 2.16Ghz Core Duo, 2GB ram, Dual 867Mhz MDD, 1.75GB ram, ATI 9800 Pro vid
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]
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.
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
Calendar interface for cocoa app
By dede94 in forum macOS - Development and DarwinReplies: 7Last Post: 05-16-2012, 08:01 AM -
OBJECTIVE-C / COCOA MacOS Developer HOME BASED required by leading Company (VACANCY)
By Leigh in forum macOS - Development and DarwinReplies: 0Last Post: 11-26-2008, 01:04 PM -
Word document on Mac based browser
By macornot in forum macOS - Development and DarwinReplies: 0Last Post: 06-06-2008, 03:50 AM -
Any cocoa developers for hire (project based)?
By giulio in forum macOS - Development and DarwinReplies: 0Last Post: 03-31-2008, 04:55 PM -
Ways to tell the difference between a Cocoa app and a Carbon app
By remain in forum macOS - Apps and GamesReplies: 0Last Post: 05-22-2007, 08:55 AM