• 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: j o a r <email@hidden>
  • Date: Sat, 22 Mar 2003 16:36:26 +0100

On Saturday, Mar 22, 2003, at 14:43 Europe/Stockholm, Ben Dougall wrote:

objects? do you mean classes or instances there?

It's OK that you have created a little vocabulary of your own for dealing with these things, but in general "object" will always be used to denote an instance of a class. Don't make this thread any more confusing than what it already is.

no i am not thinking of something else. my point is that the number of and the names of the object instances that i wish to use during runtime is unknown at compilation. hence why i'm asking for object instance variable names. i've already written several emails - read those, and if what i want still isn't clear (which i'm not saying is unlikely - far from it - i realise that it may still not be clear) but there's no point in me repeating all that. i get the feeling you haven't seen the previous mails.

Stop writing about this, and research the use of dictionaries as you have been instructed - this will save you time, and save bandwidth for the rest of us. Read the last email from Sherm Pendley carefully, as it is probably right on target for you.

On Saturday, Mar 22, 2003, at 14:45 Europe/Stockholm, Ben Dougall wrote:

Maybe I am missing something here but when I first read your post I thought you were referring to instantiated objects based on the name. If that is so then you can use "NSClassFromString" (documented in Foundation functions under "Objective-C Runtime" to do something like this:

NSString *myClassName = @"Some class name that could come from a variable";
id myObject = [[NSClassFromString(myClassName) alloc] init];

That will instantiate an instance of the class with the given name (or return nil if it doesn't exist).

jeff, thanks very much for the reply. if you have got the wrong end of the stick, i'm sure nearly all (if not all) the blame is on me. :) (that's obvious)

for a second, knee jerk reaction & first thing in the morning, i thought this might be exactly what i'm looking for. but i don't think it is. someghing like NSInstanceOfClassFromString could have been it, but obviously that's a made up name. i haven't looked into NSClassFromString in detail yet - i've got a few things to follow up - but from what i can understand immediately it doesn't look like what i'm looking for.

FYI, and as a correction to the post from Jeff: You cannot be sure that [[SomeClass alloc] init] will return a valid, functional, instance - since you need to respect the default initializer of the class. For NSView this is initWithFrame:, as an example.

j o a r
_______________________________________________
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.

References: 
 >Re: object instance names generated on the fly? (From: Ben Dougall <email@hidden>)

  • Prev by Date: Mounting remote volumes wit URL
  • Next by Date: AECreateAppleEvent
  • 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