从 NSString 中检索值

发布于 2024-09-05 16:22:44 字数 178 浏览 4 评论 0原文

我有一个 NSString 实例,我想从中检索值并将其存储到一个整数中。 这是我正在做的事情,但它不起作用。

NSString *totalcnt;
char *str = totalcnt;
int a = atoi(str);

帮帮我吧。 谢谢泰穆尔

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

暮年慕年 2024-09-12 16:22:44

如果您正在处理 Objective-C 对象,请使用 Objective-C:

int a = [totalcnt intValue];

参考:intValue


在您的代码示例中,您没有实例化 NSString 但我希望您的在你的真实代码中做到这一点。否则,totalcnt 是一个野指针

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.

挖鼻大婶 2024-09-12 16:22:44
int a = [totalcnt intValue];
int a = [totalcnt intValue];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文