• 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: 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.

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

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