例如,当将 value
消息传递给 NSInteger
实例时
[a value]
它会导致 EXC_BAD_ACCESS。
那么如何将 NSInteger
转换为 int
?
如果相关,则只使用
最佳答案
塔达:
NSInteger myInteger = 42;
int myInt = (int) myInteger;
NSInteger
只不过是一个 32/64 位的整数。 (它将根据您运行的操作系统/平台使用适当的大小)
https://stackoverflow.com/questions/1752701/
相关文章:
objective-c - 如何摆脱 Xcode 中的 "unused variable"警告?
ios - 无法在模拟器中运行应用程序 : An error was encountered whi
objective-c - 将 writeToFile :atomically: overwrite
objective-c - 是什么让钥匙串(keychain)项目独一无二(在 iOS 中)?
java - Java接口(interface)和Objective-C协议(protocol)的区
ios - UICollectionView 的 cellForItemAtIndexPath 没有