开发者

Retrieve Value from NSString

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.


int a = [totalcnt intValue];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜