objective-c - for 循环在editingStyleForRowAtIndexPath 中仅执行一次

标签 objective-c ios for-loop tableview

代码:

if(self.editing == YES)
{
    if(self.editing == YES && indexPath.section == 7 && indexPath.row == [[self pickGoalsFromAnd:0] count])
    {   
        NSLog(@"INSERT editingStyleForRowAtIndexPath.section: %d", (indexPath.section));
        return UITableViewCellEditingStyleInsert;
    }
    NSLog(@"Net voor FORLUS");
    for(int sectieId = 0; sectieId < [[self pickAnd] count]; sectieId++)
    {

        NSLog(@"Binnen FORLUS , sectieId/pickAndCount: (%d)/(%d)", sectieId, [[self pickAnd] count]);

        sectieId = sectieId + 8;
        NSLog(@"indexPath.section '==' %d '&&' indexPath.row '==' %d", sectieId , [[self pickGoalsFromAnd:(sectieId-8)] count]  );

                    if(indexPath.section == sectieId && indexPath.row < [[self pickGoalsFromAnd:(sectieId-8)] count])
                    {
                        NSLog(@"INSERT editingStyleForRowAtIndexPath.section: %d", (indexPath.section));
                    return UITableViewCellEditingStyleInsert;
                    }
                    else 
                        if(indexPath.section != ([[self pickAnd] count] + 7))
                        {
                    {
                        NSLog(@"ifELSE");
        return UITableViewCellEditingStyleDelete;
                    }
                        }
    }

正如我使用 NSLogs 所看到的,for 循环只执行一次。 for 循环是否有可能在“返回”某些内容时停止?

For循环:for(int sectieId = 0; sectieId < [[self pickAnd] count]; sectieId++)

最佳答案

一旦返回,就会退出该函数并且循环会中断,因此它只执行一次。

关于objective-c - for 循环在editingStyleForRowAtIndexPath 中仅执行一次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13383276/

相关文章:

iphone - 检查 NSString 是否同时包含字母和数字

objective-c - 初始化 NSMutableArray 的正确方法

objective-c - 使用 ARC 的自定义委托(delegate) iOS 6 不起作用

c++ - 在循环中为 C++ 创建对象

计算文本文件中出现的所有字符

objective-c - 我应该使用 @property (retain) 作为保留的 @dynamic 属性 setter 吗?

ios - 如何设置 UIPickerView 的默认值

ios - 移除 Retina 版本后图像仍能正确显示(?)

ios - iPad 在 subview Controller 中显示 UIActionSheet 时崩溃

c++11 - 何时更喜欢 for 循环而不是 std::transform,反之亦然