• 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: object instance names generated on the fly?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: object instance names generated on the fly?


  • Subject: Re: object instance names generated on the fly?
  • From: marquis logan <email@hidden>
  • Date: Fri, 21 Mar 2003 14:32:32 -0800

On Friday, March 21, 2003, at 07:48AM, Ben Dougall <email@hidden> wrote:

>thanks for the reply.
>
>because an array will behave in a very different way to my object. i
>want to initiate this object many times, so i guess the precise
>question is: is it possible to initiate an object with a name that's a
>variable? rather than what seems to be the norm - with a name that
>you've typed in the code.

like a class variable?

in obj-c you could use a static global variable in the source file for your class. like:

static NSString *_myName = nil;
static UInt32 _myCount = 0x00;

//before you ever create an instance
+(void)setObjectName: (NString *)name
{
if(! _myName)
_myName = [name retain];
}

//whenever you need a new name
+ (NSString *)newInstanceName
{
return([NSString stringWithFormat: @"%@%u", _myName, _myCount++]);
}


nibs
_______________________________________________
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.

  • Prev by Date: Re: object instance names generated on the fly?
  • Next by Date: Re: object instance names generated on the fly?
  • Previous by thread: Re: object instance names generated on the fly?
  • Next by thread: Re: object instance names generated on the fly?
  • Index(es):
    • Date
    • Thread