Re: Where to put global variables in Cocoa?
Re: Where to put global variables in Cocoa?
- Subject: Re: Where to put global variables in Cocoa?
- From: David Remahl <email@hidden>
- 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.