如何将NSInteger转换为int? [英] How to convert An NSInteger to an int?

查看:104
本文介绍了如何将NSInteger转换为int?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,当向 NSInteger 实例传递消息时,像

For example when passing a value message to an NSInteger instance like so

[a value] 它会导致EXC_BAD_ACCESS。

[a value] it causes an EXC_BAD_ACCESS.

code> NSInteger 到 int

So how to convert an NSInteger to int?

< 32。

推荐答案

Ta da:

NSInteger myInteger = 42;
int myInt = (int) myInteger;

NSInteger 64位整数。 (它将使用基于您运行的操作系统/平台的适当大小)

NSInteger is nothing more than a 32/64 bit int. (it will use the appropriate size based on what OS/platform you're running)

这篇关于如何将NSInteger转换为int?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆