循环比较indexPaths iphone

发布于 2024-09-02 06:36:52 字数 413 浏览 3 评论 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. 

} 

I am trying to compare an index path in my didSelectRowAtIndexPath delegate method with an array of index paths.

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. 

} 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

轻拂→两袖风尘 2024-09-09 06:36:52

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

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

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

在 Cocoa API 中,有一些非类- 使用中的类型。最重要的是来自 基础数据类型,其中包括

  • 的枚举typedef
  • 整数类型
  • 结构

Use NSOrderedSame and no pointer - NSComparisonResult is just an integer:

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

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

In the Cocoa APIs, there are some non-class-types in use. Most important are those from the Foundation data types, which include

  • enumerations
  • typedefs for integral types
  • structures
忘东忘西忘不掉你 2024-09-09 06:36:52

它只是一个包含以下值之一的 int:

  • NSOrderedAscending
  • NSOrderedSame
  • NSOrderedDescending

在您的情况下,测试 NSOrderedSame

if (result == NSOrderedSame) {
    ...
}

It's just an int holding one of these values:

  • NSOrderedAscending
  • NSOrderedSame
  • NSOrderedDescending

In your case, test for NSOrderedSame:

if (result == NSOrderedSame) {
    ...
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文