在init中创建后NSMutableArray为空(带代码)

W D*_*son 0 xcode objective-c nsmutablearray ios

@property(nonatomic,strong)NSMutableArray*authorMutableArray;

- (id)init {
    self = [super init];
    if (self) {

        self.authorMutableArray = [[NSMutableArray alloc] initWithObjects:@"First Row", @"Second Row", nil];

        for (NSString *string in authorMutableArray) {
            NSLog(@"String: %@", string);
        }

        NSLog(@"Init in Add Model with Author count:%i", [authorMutableArray count]);


    }
}
Run Code Online (Sandbox Code Playgroud)

访问该属性的示例.NSLog始终将计数显示为0.

    - (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section == 0) { 
        if (indexPath.row == [self.addModel.authorMutableArray count] - 1 ) {
            NSLog(@"count of %i", [self.addModel.authorMutableArray count]);
            return  UITableViewCellEditingStyleInsert;
        }

        else {
            return  UITableViewCellEditingStyleDelete;

        }
    }

    else {
        return UITableViewCellEditingStyleNone;
    }
}
Run Code Online (Sandbox Code Playgroud)

我在init中创建的数组没有保持其值超过此方法.有什么理由吗?for循环将显示数组中的两个对象.如果我在调用init方法后尝试询问此问题,则该数组为空.

更新:感谢大家的时间和眼睛.我忘了在init方法中返回self.

pre*_*pre 5

init方法不应该返回self吗?