surendher
surendher

Reputation: 1378

How to create an NSMutableArray Dynamically?

I want to create an array with the name the user has given as input in textfield, for this i want to know how to create an array dynamically.

Any help will be appreciated

Upvotes: 1

Views: 1019

Answers (2)

John Smith
John Smith

Reputation: 2022

You can dynamically declare an array, but you can never use an input string as a name of your object's array.

Say what is you target, and we could help you to solve it. It looks like you want do do something and you are taking the wrong approach, if you have such request.

Upvotes: 0

Dan F
Dan F

Reputation: 17732

If you mean a dynamic variable name, then the only way you can sort of accomplish this is by creating the array and then storing it in a dictionary:

NSMutableDictionary *myArrays;//declared and initialized somewhere

NSMutableArray *newArray = [[NSMutableArray alloc] init];
[myArrays addObject:newArray forKey:someLabel.text];

Upvotes: 1

Related Questions