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: James Mooney <email@hidden>
- Date: Sat, 22 Mar 2003 11:46:59 -0500
Ben,
I think after reading what you mention and the responses is that you
are posed with an issue of the unknown. You create a class and you
want to create many instance objects of the class. You made the
assumption that you need to name each instance a new name. On the
surface that is reasonable. But of course as you write the code, the
name becomes the huge issue.
Conceptually it would be nice to dump the new instance of the class you
created, the whole thing, into a repository. The repository then
contains a copy of the instance of the class you created. When you are
done adding the object to the repository, you get rid of the original
instance. Now all you have to do is know the location in the
repository of the object you created to reference it, call one of it;s
methods, or to change a value of an instance variable.
I had this same problem in Java and "discovered" a beautiful data
structure/class called a Vector. << a class which holds a collection of
instantiated objects, which can be the same or objects of completely
different types.
"Sets" and "Dictionaries" are similiar to Vectors in that they allow
the collection of objects. Chuck an object into a one of the two to
access them at a later date in the application. When it comes time to
delete of create new objects, you can make a call to the location in
the Dictionaries or Sets to do your work.
Jim
On Friday, March 21, 2003, at 05:49 AM, Ben Dougall wrote:
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.