Quote:
Originally Posted by lll3mk4
Hello I would like to make an NSmutableArray and add 3 text fields to the NSmutableArray so I dont need to repeat this code three times.
if ([textfield1.text length] >= 3) {
textfield1.text = [textfield1.text substringWithRange:NSMakeRange(0,2)];
But when ever I add the three text fields to the NSmutableArray it wont let me replace the "textfield1.text" with "NSmutableArray.text" why is this? Is there another way that might solve my problem!
Thanks
|
Mutable arrays don't have a text property. NSMutableArrays contain arrays of other objects. Sometimes those objects are strings, sometimes other kinds of objects.
What is it you want? The string object at a particular index, or all the strings at all the array indexes combined together?
If you just need one of the strings at a particular index, you could use something like
Code:
[myArray objectAtIndex: index]; //My array is a mutable array created elsewhere
As the other poster said.
If you want to combine all the strings together, you need to write code to do that.
Something like this:
Code:
NSMutableString* combinedString;
combinedString = [NSMutableString stringWithCapacity: 50];
NSString* aString;
for (aString in myArray)
[combinedString appendString: aString];