Reputation: 339
I have this and it works:
[pole insertObject: [NSString stringWithFormat:@"%s",[textfield text]] atIndex:idpole];
But this doesn't save to string what is in the texfield, but some numbers or other unspecified characters. What can I do, to save real text from a textfield?
Upvotes: 0
Views: 1997
Reputation: 4606
[pole insertObject: [NSString stringWithFormat:@"%@",[textfield text]] atIndex:idpole];
NSlog(@"%@",pole);
Upvotes: 1
Reputation: 3243
Thats because [textfield text] is a reference to a NSString object.
Upvotes: 1
Reputation: 69469
There is no need to create a new string:
[pole insertObject: [textfield text] atIndex:idpole];
Or if you want to make sure the the string a new object:
[pole insertObject: [NSString stringWithString:[textfield text]] atIndex:idpole];
Upvotes: 4