草庐IT

NSNotFound

全部标签

ios - NSNotFound 比较不起作用

关闭。这个问题是notreproducibleorwascausedbytypos.它目前不接受答案。这个问题是由于错别字或无法再重现的问题引起的。虽然类似的问题可能是on-topic在这里,这个问题的解决方式不太可能帮助future的读者。关闭8年前。Improvethisquestion简单的。我正在使用indexOfObject检查一个值是否已经在数组中。如果该值不在数组indexOfObject中,则返回常量NSNotFound。为什么与>100000比较有效:NSIntegerindexOfCell=[_selectedCellIndicesindexOfObject:cel

ios - 这是 NSIndexSet enumerateIndexesUsingBlock 中的错误吗?

在我的单元测试中,我查看了一些边界条件,但我的测试一直失败。当它的索引一直延伸到NSNotFound-1(每个文档的最大合法值)时,我追踪到它通过索引集进行枚举。使用这个测试代码://CreateanindexsetwithNSNotFound-5,NSNotFound-4,NSNotFound-3,//NSNotFound-2andNSNotFound-1NSIndexSet*testSet=[NSIndexSetindexSetWithIndexesInRange:NSMakeRange(NSNotFound-5,5)];NSLog(@"Indexsetwith%luentries

ios - 当 for 循环从 NSArray 到达 NSNotFound 时如何中断

我有一个nsmutablearray,我在一个nsarray的for循环中向它添加对象。我希望它添加对象,直到它从NSArray到达indexOfObject:中的NSNotFound。该数组位于for循环内,用于从每个索引中提取字符串。我的代码:NSIntegeruntilNotFound=NSNotFound;NSUIntegerindex=[arrayindexOfObject:string];for(index;index编辑:for(stringinarray){NSComparisonResult*result=[stringcompare:searchTextoption

ios - 什么是 NSNotFound 的 float

如果我有一个返回CGFloat的方法并且该方法找不到预期的数字怎么办,我想返回类似NSNotFound的东西,但那是一个NSInteger。最佳实践是什么? 最佳答案 您可以使用不是数字(NaN)。参见nan(),nanf()和isnan().但是对于这些问题,没有明确定义的非值(整数更糟糕),那么我更喜欢使用以下方法语义:-(BOOL)parseString:(NSString*)stringtoFloat:(CGFloat*)value{//parsestringhereif(parsed_string_ok){if(value

objective-c - 为 NSUInteger 返回 NSNotFound 是否可取?

我正在为NSArray开发一个类别,我实现的其中一个函数旨在返回数组中的字符串数(或不是数字)。这一切都很好,但我的问题是关于在输入数组的计数为零的情况下使用NSNotFound作为返回。Apple的文档状态:NSNotFoundistypicallyusedbyvariousmethodsandfunctionsthatsearchforitemsinserialdataandreturnindices,suchascharactersinastringobjectoridsinanNSArrayobject.如果我要对不在数组中的项目使用indexOfObject:,这就完全有意义

ios - NSNotFound 的可用性如何?

NSNotFound的Xcode文档非常困惑:上面写着“在iOS2.0到8.4中可用”和“可用性:iOS8.1到8.0”。所以...8.0之前可以用吗?还是9.0+?另外,如果是的话,这是怎么回事? 最佳答案 插入availabilityOfNSNotFound==NSNotFound开个玩笑。在Apple插入强制性64位设备支持(iOS8.4SDK?)的某个时刻,NSNotFound的声明更改自:enum{NSNotFound=NSIntegerMax};到staticconstNSIntegerNSNotFound=NSInte

ios - Swift:对 NSNotFound 的模糊引用

在向一些Objective-C代码添加桥接header后,我开始收到有关NSNotFound是不明确引用的编译器错误。我的猜测是它可以用某种模块前缀来修复... 最佳答案 是的。将其更改为:Foundation.NSNotFound 关于ios-Swift:对NSNotFound的模糊引用,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/24731622/