cocoa-touch - NSString 到 NSUInteger

标签 cocoa-touch iphone-sdk-3.0 nsstring nsuinteger

我在 NSString 中有一个数字 @"15" .我想将其转换为 NSUInteger,但我不知道该怎么做...

最佳答案

NSString *str = @"15";
// Extract an integer number, returns 0 if there's no valid number at the start of the string.
NSInteger i = [str integerValue];

如果你真的想要一个 NSUInteger,直接转换它,但你可能想事先测试这个值。

关于cocoa-touch - NSString 到 NSUInteger,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2749720/

相关文章:

cocoa-touch - 使用colorWithRed:green:blue:alpha时,iOS App崩溃

iPhone 和 Ipad - 如何获取代码?

ios - 带有 EMOJI 的文本字符串导致 NSRange 出现问题

iphone - 如何从 iPhone 的字符串中删除标签?

ios - 切换 View 会使应用程序崩溃

iphone - 为什么 Apple 说 iPhone 应用程序使用 MVC?

iphone - 检查缩放级别是否改变

NSString boundingRectWithSize 边界不被尊重

ios - 自定义 UICollectionView 布局中列中的单元格对

ios - 2个MKA注释之间的距离?