0

我正在尝试将 didSelectRowAtIndexPath 委托方法中的索引路径与索引路径数组进行比较。

for (n=0; n < [tempMutArrray count]; n= n+1){

     NSComparisonResult *result = [indexPath compare:[tempMutArray objectAtIndex:n];

//What I want to do is is write an if statement that executes a certain block of code 
//if the two index paths are equal, but I cant figure out how to work with an 
//NSComparisonResult. 

} 
4

2 回答 2

1

使用NSOrderedSame并且没有指针 -NSComparisonResult只是一个整数:

NSComparisonResult result = [indexPath compare:[tempMutArray objectAtIndex:n];

if(result == NSOrderedSame) {
    // do stuff
}

在 Cocoa API 中,使用了一些非类类型。最重要的是来自Foundation 数据类型的那些,其中包括

  • 枚举
  • 整数类型的 typedef
  • 结构
于 2010-05-19T14:09:20.893 回答
1

它只是一个 int 持有这些值之一:

  • NSOrderedAscending
  • NSOrderedSame
  • NSOrderedDescending

在您的情况下,测试NSOrderedSame

if (result == NSOrderedSame) {
    ...
}
于 2010-05-19T14:09:58.820 回答