• 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: define class variable
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: define class variable


  • Subject: Re: define class variable
  • From: j o a r <email@hidden>
  • Date: Thu, 1 Aug 2002 11:39:19 +0200

Something like this:

@implementation MyClass

static NSString *myGlobalString = nil;

+ (void) setResult:(NSString *) newResult
{
[myGlobalString autorelease];
myGlobalString = [newResult retain];
}

+ (NSString *) getResult
{
return myGlobalString;
}

@end

The space within brackets in the @interface declaration of a class is reserved for instance variables, not class variables.

j o a r

On Thursday, August 1, 2002, at 11:35 , Chong Hiu Pun wrote:

How to define class variable which can be access by class method ( e.g
+(NSString*)GetResult; )
Thanks.

ps: I defined under
@interface my_class_name : NSObject
{
....
NSString strResult; //define here, but receive compiler warning
...
}
_______________________________________________
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.

  • Follow-Ups:
    • Re: define class variable
      • From: Ondra Cada <email@hidden>
References: 
 >define class variable (From: "Chong Hiu Pun" <email@hidden>)

  • Prev by Date: init function return value
  • Next by Date: 2 classes
  • Previous by thread: define class variable
  • Next by thread: Re: define class variable
  • Index(es):
    • Date
    • Thread