Hi, i have a NSString instance ,i want to retrieve value from it and store it into an integer. This is wat i am doing but its not working.
NSString *totalcnt;
char *str = totalcnt;
int a = atoi(str);
Help me out. Thanks
Taimur
Hi, i have a NSString instance ,i want to retrieve value from it and store it into an integer. This is wat i am doing but its not working.
NSString *totalcnt;
char *str = totalcnt;
int a = atoi(str);
Help me out. Thanks
Taimur
If you are dealing with Objective-C objects, use Objective-C:
int a = [totalcnt intValue];
Reference: intValue
In your code example, you don't instantiate a NSString but I hope your are doing it in your real code. Otherwise, totalcnt
is a wild pointer.