새내기 (C, objective-C 및 iOS) ...갓 초기화 된 배열이 비어 있습니다 - 왜?
내 AppDelegate.m의이 코드는 왜 새로 초기화 된 배열이 비어 있습니까? 내가 어떤 가치관을주는 것처럼 보입니다. 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;
}
ARC를 사용하고 있습니까? 그렇지 않다면 clueLabs는 보존 된 속성입니까? 그렇다면, 당신은 그것을 지키고 있습니다. – Till
예, ARC가 켜져 있습니다. 헤더 파일에 "IBOutlet UILabel * Clue1;"이 포함되어 있습니다. 와 '@property (strong) UILabel * Clue1'각 단서에 대해 –