OGeek|极客世界-中国程序员成长平台

标题: objective-c - 刚初始化的数组是空的 - 为什么? [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-13 11:04
标题: objective-c - 刚初始化的数组是空的 - 为什么?

这里的新手(到 C、objective-C 和 iOS)...

对于我 AppDelegate.m 中的这段代码,为什么刚初始化的数组是空的?在我看来,我给了它一些值(value)。 Clue1 等是一系列 UILabels,Xcode 没有注意到任何问题。我已经经历了很多,这似乎是这样做的方法。 Xcode 4.2。谢谢!

- (id)init {       
    self = [super init];
    if(self) {           
        // Make arrays containing the objects: this is the objective-C way!
       self.clueLabs = [[NSMutableArray alloc] initWithObjects: Clue1, Clue2, Clue3, nil];
    }   
    NSLog(@"%@", [clueLabs description]);
    if (!clueLabs || ![clueLabs count]) { // these 2 do m/l the same thing
        NSLog(@"clueLabs is empty!");
    }       
    return self; 
}



Best Answer-推荐答案


检查 Clue1、Clue2 Clue3 是否不为零。

关于objective-c - 刚初始化的数组是空的 - 为什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9050912/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4