• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Where to put global variables in Cocoa?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Where to put global variables in Cocoa?


  • Subject: Re: Where to put global variables in Cocoa?
  • From: "Peter Karlsson" <email@hidden>
  • Date: Fri, 07 Mar 2003 08:57:59 +0000

If possible, you should store the midi settings in an object, and do [settings reset] on that object.

What do you mean here? If I for example want to save a midi channel so I can use that value anywhere in my code. Any code example?

Peter

From: David Remahl <email@hidden>
To: "Peter Karlsson" <email@hidden>
CC: email@hidden
Subject: Re: Where to put global variables in Cocoa?
Date: Thu, 6 Mar 2003 10:17:43 +0100

Hej Peter!

In many cases you shouldn't use global variables at all.

But this is the way you do it:

In midireset.h:

extern int aGlobalInteger;

In midireset.m

int aGlobalInteger = 0;

In otherfile.h

#import midireset.h

In otherfile.m

printf("A global integer: %i\",aGlobalInteger);

If possible, you should store the midi settings in an object, and do do [settings reset] on that object. This will make it easier to, for example, have several sets of settings, and switch between them simply by exchanging the settings instance.

/ Mvh, David

Hi dear list!

I have a implementation file called Controller.m and from that file I call a regular C function like this:

- (IBAction)resetAction:(id)sender
{
midireset();
}

I also have my global variables in the same file, don't know if that is right or wrong. The midireset function is located in another file called midireset.m But it seems that the function does not see my global variables. So the queston is:

Where is the right place to put my global variables in Cocoa?

Best regards Peter





_________________________________________________________________
MSN 8 with e-mail virus protection service: 2 months FREE* http://join.msn.com/?page=features/virus
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

_________________________________________________________________
Add photos to your e-mail with MSN 8. Get 2 months FREE*. http://join.msn.com/?page=features/featuredemail
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
  • Follow-Ups:
    • Re: Where to put global variables in Cocoa?
      • From: j o a r <email@hidden>
  • Prev by Date: Re: java-dev digest, Vol 3 #1137 - 13 msgs
  • Next by Date: Re: Where to put global variables in Cocoa?
  • Previous by thread: Re: Where to put global variables in Cocoa?
  • Next by thread: Re: Where to put global variables in Cocoa?
  • Index(es):
    • Date
    • Thread