discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSMutableArray variable using an NSString???


From: Dr. H. Nikolaus Schaller
Subject: Re: NSMutableArray variable using an NSString???
Date: Sun, 20 Feb 2011 19:05:29 +0100

Ah, I see.

Us a NSMutableDictionary where the key is e.g. "Weight" and store a
NSMutableArray as the value.

Am 20.02.2011 um 18:40 schrieb Jeric Batarina:

> I was planning to create an Array whose name is according to the user's input.
> like, if I entered "Weight", the program creates an array for weights.
> 
> On 2/21/11, Dr. H. Nikolaus Schaller <hns@goldelico.com> wrote:
>> 
>> Am 20.02.2011 um 17:49 schrieb Jeric Batarina:
>> 
>>> Is it possible to use NSString as the variable to create an
>>> NSMutableArray?
>>> 
>>> My thoughts is that it'd go like this:
>>> 
>>> NSMutableArray [NSString stringWithCString: <variableName>] =
>>> [NSMutableArray new];
>>> 
>>> Any ideas if this'd work?
>> 
>> a) No, because variable names are analyzed by the compilers at compile time
>> (it is not an interpreter)
>> b) What do you need it for? If you think you need it you have some
>> fundamental flaw in your application architecture.
>> c) you can dynamically access instance variables (with fixed name) through
>> KVC. This uses a NSString as the path.
>>    It works because the compiler stores a table of all instance variable
>> names in the executable code.
>> 
>> -- hns
>> 
>> 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]