ios - NSMakeRange(i, 1) 是什么意思?

标签 ios objective-c cocoa-touch

我刚开始学习iOS。
NSMakeRange(i, 1)”是什么意思?

for (int i = 0; i < [name length]; i++)
{
    NSRange range = NSMakeRange(i, 1);
    NSString *subString = [name substringWithRange:range];
    const char *cString = [subString UTF8String];
    if (strlen(cString) != 3)
    {
        return NO;
    }
}

用在什么地方?

最佳答案

NSMakeRange(i, 1) 创建一个范围,位置为 i,长度为 1。请参阅 NSMakeRange 的文档和 NSString substringWithRange了解更多信息和相关功能。

关于ios - NSMakeRange(i, 1) 是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14412820/

相关文章:

objective-c - Objective-C - UITableViewCell 异步加载图像

ios - 为背景音频设置锁屏图像

objective-c - 当我的 UIViewController 弹出时调用的方法?

iphone - Objective-C 中的文本作为超链接

ios - 解析 Facebook - clang : error: linker command failed with exit code 1 (use -v to see invocation)

ios - AppDelegate 中的 Swift UITabbar Shadow

ios - 如何在 iOS 8 中为以前接受过通知的用户启用推送通知?

iphone - 选择 UITableView 的多行

iphone - 操作无法完成。 ( cocoa 错误 260。)

ios - 核心数据 : how to organize contacts (entity) into sections based on the first letter of their names?