0

如何指定我想在没有任何选项的情况下“枚举ObjectsAtIndexes:”?当我尝试将 nil 传递给 options 参数时,Xcode 给了我这个警告。不会引起投诉的等值价值是多少?

4

2 回答 2

3

opts是一个枚举,(在这种情况下)基本上是 and unsigned int,所以 pass 0

于 2013-03-23T13:02:03.797 回答
2

https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Miscellaneous/Foundation_Constants/Reference/reference.html#//apple_ref/doc/c_ref/NSEnumerationOptions

阅读有关此方法的 NSArray 文档,然后单击描述中的 NSEnumerationOptions 链接。

NSEnumerationOptions

块枚举操作的选项。

enum {
   NSEnumerationConcurrent = (1UL << 0),
   NSEnumerationReverse = (1UL << 1),
};
typedef NSUInteger NSEnumerationOptions;

显然它是一个 NSUInteger 位被屏蔽。0 或以上两者之一或两者,但NSEnumerationConcurrent注意仅作为提示且不保证。

nil不是一个NSUInteger。并非所有方法参数都是对象。nil仅当对象参数是可选的时才应传递。

于 2013-03-23T13:10:27.710 回答