这是NSIndexSet中的一个错误enumerateIndexesUsingBlock吗?

Lav*_*der 6 macos cocoa nsindexset ios

在我的单元测试中,我正在查看一些边界条件,我的测试仍然失败.当它的索引一直扩展到NSNotFound-1(每个文档的最大合法值)时,我将其追溯到枚举索引集.

使用此测试代码:

// Create an index set with NSNotFound-5, NSNotFound-4, NSNotFound-3, 
// NSNotFound-2 and NSNotFound-1
NSIndexSet *testSet = [NSIndexSet indexSetWithIndexesInRange:
    NSMakeRange( NSNotFound - 5, 5 )];
NSLog( @"Index set with %lu entries: %@", (unsigned long) testSet.count, testSet );
NSLog( @"NSNotFound is %lu and NSNotFound-1 is %lu", NSNotFound, NSNotFound - 1 );
__block int count = 0;
[testSet enumerateIndexesUsingBlock:^(NSUInteger idx, BOOL *stop) {
    NSLog( @"- %lu", (unsigned long) idx );
    ++count;
}];
NSLog( @"The count is %d", count );
Run Code Online (Sandbox Code Playgroud)

在日志输出中我得到:

Index set with 5 entries: <NSIndexSet: 0x10057f890>[number of indexes: 5 (in 1 ranges), indexes: (9223372036854775802-9223372036854775806)]  
NSNotFound is 9223372036854775807 and NSNotFound-1 is 9223372036854775806  
- 9223372036854775802  
- 9223372036854775803  
- 9223372036854775804  
- 9223372036854775805  
The count is 4  
Run Code Online (Sandbox Code Playgroud)

我在我的Mac和iOS模拟器上尝试了这个并获得相同的结果(除了NSNotFound的实际值,取决于32位或64位).

这让我想到也许我正在阅读文档错误.我做错了什么或这是一个苹果虫?

Lav*_*der 0

好吧,看来我已经确认这是/曾经是一个错误。我提交了一份错误报告,并从 Apple 获悉该问题已在最新的 OS X Yosemite 开发者预览版和 Xcode 预览版中修复。我下载了它,它似乎按照文档中的预期工作。

我怀疑他们必须更改一行代码,因此询问他们是否会修补当前或以前版本的 Xcode,但我没有听说过,而且我也没有屏住呼吸。