Re: object instance names generated on the fly?
Re: object instance names generated on the fly?
- Subject: Re: object instance names generated on the fly?
- From: Ben Dougall <email@hidden>
- Date: Fri, 21 Mar 2003 22:03:03 +0000
What would an object's "name" be, anyway? Are you referring to the
label given to the object pointer? In:
id blah = [[NSObject alloc] init];
Would "blah" be the name?
yes, that's the name i mean. so depending on the situation, the code
maybe required to initiate blah0 instance and blah1 instance of the
object, or blah0.....blah50 instances of the object.
If so, "blah" would be limited in scope the same way any variable name
would be. I am having trouble imagining how it would do you any good
to have a programmatically-generated name;
i want to create multiple instances of a particular object. the number
of instances will be based absolutely on information that is input into
the application by the user (the amount of it). small amount of info
input = small number of objects instances initiated. large amount of
info input = large number of object instances initiated.
the data inputted and the objects are very much tied up together. to be
viewed as the same thing in the application. so the more information
input, the more instances of this object. the two things completely
correlate.
if you're not still in the same scope as the declaration, you're going
to lose the tag to it anyway when you pop the stack.
the naming will follow a system and the progress of what objects have
been created will be recorded in a known standard place. a referable by
all place - like a notice board, so the names won't get lost, if that's
what you mean there.
You could maybe fprintf the code out to a .m file, invoke the compiler
and load it as a shared library. That would be the act of a >
smart-ass.
sounds a bit over the top. but my whole idea is pretty tied up with
initiating objects with names that are variables, so if something like
that is the only way - who knows? it does sound overly elaborate though.
Otherwise, I think an [NSMutableDictionary addObject:[[NSObject alloc]
init] withKey:<generated name>] is probably the way to go.
that looks possible/hopeful. don't really understand it though, only
because i don't know obj-c/cocoa properly yet. which object in that
would be the one that's the main one being added there? the NSObject?
so that would be replaced with myObject? and all the instances would
reside in a NSMutableDictionary instance? so NSMutableDictionary is
what's being used to tie the various instances together,
incorporating/using a variable instance name? yup, i will have to look
into this for sure.
damn. i did think there was a possibility that what i'm asking for was
almost completely standard, done all the time, but obviously not from
the responses :/
i'm sure there's technically a way to do what i want without any of
this variable object instance names stuff, but variable object instance
names is very tied up with my idea, and structure of it, so i would
like to achieve variable object instance names somehow, even if it
requires a smart-ass solution. but not too smart-ass.
thanks v. much for the info.
Christian
On Friday, March 21, 2003, at 07:48 am, Ben Dougall 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.
On Friday, March 21, 2003, at 03:14 pm, email@hidden
wrote:
Why don't you just use an array? or a dictionary if you really have
to
give each instance a name...
John.
Ben Dougall <email@hidden>
Sent by: email@hidden
03/21/2003 10:49 AM
To: email@hidden
cc:
Subject: object instance names generated on the fly?
only just starting cocoa/obj-c so this might be very easy to do, or
impossible. i have no idea.
is it possible to get various object instances from one class with
names based/generated from a variable rather than names that have
been
typed into the code - so a series of object instances whos names have
been generated by using a for loop for instance?
thanks.
_______________________________________________
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.
_______________________________________________
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.