Reputation: 2051
I have a UITextField called txtvwEmail
. i am adding the text from txtvwEmail.text
to the Array pastUrls
but after adding the next text it remove the first text. Im using the code
if (![pastUrls containsObject:txtvwEmail.text]) {
[pastUrls addObject:txtvwEmail.text];
}
Upvotes: 0
Views: 150
Reputation: 25692
//this should be outside of ur all loops
NSMutableArray *pastUrls=[[NSMutableArray alloc]init];
//remove this line
//NSMutableArray *pastUrls=[NSMutableArray array];
if (![pastUrls containsObject:txtvwEmail.text]) {
[pastUrls addObject:txtvwEmail.text];
}
NSLog(@"pastUrls : %@ \n\n",pastUrls);
Upvotes: 1
Reputation: 4261
You should rely on the basics of the language and frameworks. The array DOES RETAIN the object, however, it could be:
Also, you can't really be sure [obj retainCount] return the correct value. To diagnose the real problem, revise the code or post it here so we can help.
Upvotes: 2