Welcome, Guest. Please login or register.
Did you miss your activation email?
July 24, 2016, 11:33:56 AM
Home Help Search chat Login Register 
News: Read this please.The Great Kangaroo Escape Looking for reviews of the 4th ed on Amazon!   Twitter:  @skochan

+ Official Forum for Programming in Objective-C (the iPhone Programming Language) - Stephen Kochan
|-+ Old Stuff
| |-+ Parts 1 and 2
| | |-+ Questions and Discussion
| | | |-+ Can I build a string and use it to name an Object?
Pages: [1] Go Down
Author Topic: Can I build a string and use it to name an Object? (Read 1219 times)
Posts: 2

on: June 05, 2011, 12:16:48 PM

I would like to create a lot of arrays of words to speed up my program with names like a5 and c11 etc. The first would be an array of 5-letter words all beginning with a, the second an array of 11-letter words all beginning with c and so on. I can easily build the name of the array to use and send messages to for every word encountered using a couple of nested loops and examining the length of each word and its first letter.

But if I build a string "a5" how do I get from there to sending a message [a5 message]

Also, is there a way I can declare the arrays in my ArrayManager class without painstaking typing in the individual array declarations?

Thanks if anyone can help.

Steve Hill
Global Moderator
Sr. Member
Posts: 276

Reply #1 on: June 25, 2011, 04:15:41 AM

Without fully understanding your question, I'm guessing if you are going to be referencing lists of lots of words in your program, you may be better off referencing a database, as you could slow your program down some what (especially if it is an iOS program).

Hero Member
Posts: 3114

Reply #2 on: June 27, 2011, 08:26:56 AM

Yes, a database is a good suggestion.  Other data structures to consider might be arrays of arrays (that is an array whose elements are themselves arrays), or perhaps a dictionary whose key is the name in question and whose object is an array of words.  I don't fully understand your question either, but hoping my answer gives some guidance.


Pages: [1] Go Up
Jump to:

Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Entire forum contents (c) 2009 classroomM.com. All rights reserved.