I have the code [usrs addObject:usrString] I am trying to make it so that the program adds whatever the string usrString is to the array every time that you press a button, and that the string is different every time. However, whenever I run this code, it doesn't do anything. It doesn't even add an object to the array. How can I make this code do what I want?
-
1Are you using an NSMutableArray? Irrespective, we need to see the code. Also, where are you expecting the string data to come from?John Parker– John Parker2010-12-19 16:32:19 +00:00Commented Dec 19, 2010 at 16:32
-
I think this may be a rephrase of middaparka's question: have you actually created an array, or merely declared a pointer to one in your class? All objects have to be explicitly created in Objective-C.Tommy– Tommy2010-12-19 16:34:50 +00:00Commented Dec 19, 2010 at 16:34
-
I have declared the variable previously, it is a mutable array, and the string data comes from the input from a textbox, which I convert into a string.user457303– user4573032010-12-19 17:33:37 +00:00Commented Dec 19, 2010 at 17:33
-
Sorry I meant array. I have declared the array earlier.user457303– user4573032010-12-19 18:10:41 +00:00Commented Dec 19, 2010 at 18:10
Add a comment
|
1 Answer
I am going to take a shot in the dark and say that you forgot to alloc/init your NSMutableArray. In Objective-C, sending messages to nil will fail silently.
e.x.
myArray = [[NSMutableArray alloc] init];
1 Comment
user457303
This solved part of my problem thanks! However, I still would like to know how to make it add whatever string the user inputs. Thanks again!