Besi
Besi

Reputation: 22939

"Global" model in NSDocument-based application

I have a NSDocument based application, which allows the user to send messages, after he has logged in.

These should be the user's steps:

The message model is placed in the MyDocument.xib. However the user model should be place in a global place (I would say MainMenu.xib).

My question is now:

  1. Does it make sense to put the model in the MainMenu.xib and how can I access it from MyDocument.m
  2. Is there maybe a better way to do this properly without having to make a singleton class?

Upvotes: 0

Views: 309

Answers (2)

Besi
Besi

Reputation: 22939

I finally got it working with my NSApplication subclass (some say this is not the way to go). For this I had to change the principal class from NSApplication to my new custom NSApplication subclass.

Upvotes: 0

Nathan Day
Nathan Day

Reputation: 6037

I would create an NSApplication delegate and then add you functionality in you delegate or an property of you delegate, you can then use [[NSApplicaton sharedApplicaton] delegate] to get you delegate. You application delegate is the place to associate model data that is common to you application.

Upvotes: 1

Related Questions