0
내 코드 NSMutableArray를 사용하여 UILabel을 추가 할 수없는 이유는 무엇입니까?
for (int i=0; i < kNumberOfTitles; ++i) {
UILabel * aLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, i*10, 100, 30)];
[_titles addObject:aLabel];
NSAssert([_titles objectAtIndex:0] != nil, @"wrong 1");
}
NSAssert([_titles objectAtIndex:0] != nil, @"wrong 2");
((UILabel *)[_titles objectAtIndex:0]).text = @"Tel";
((UILabel *)[_titles objectAtIndex:1]).text = @"Add";
for (UILabel* aLabel in _titles) {
[self.view addSubview:aLabel];
}
첫 NSAssert 전에, 난 그냥이 전무의 발견을 검색 한 다음 새 레이블을 추가하고, 다음과 같다. 무엇이 문제입니까?
배열을 할당하고 초기화합니까? –