Obj-C의 메모리 및 그 개념의 일부를 이해하는 데 여전히 어려움이 있습니다.NSMutableArray는 항상 비어 있습니까?
그래서 내 메인 클래스에는 일부 문자와 무기 목록이 포함 된 NSMutableArray
이 포함되어 있습니다. 그것은 다음과 같이이다 :
홈페이지 class.m의 init 주요 class.h
@property (nonatomic, retain) NSMutableArray *players;
에서
for(int i = 0 ; i < 30 ; i++)
{
[players addObject:[[PlayerInGame alloc] init:[self.tabPlayers objectAtIndex:i] :[self.tabWeapons:objectAtIndex:i]]];
}
PlayerInGame.h
@property (nonatomic, retain) NSMutableArray *weaponsList;
PlayerInGame.m
- (id) init : (Player*) player : (Weapon*) weapon
{
[self.weaponsList addObject:weapon];
// Then I try NSLog of weaponsList's count.
}
여기 weaponsList 항상 비어 있습니다. 뭐가 잘못 되었 니?
의 중복 가능성 [빈있는 NSMutableArray, 확실하지 않은 이유 (http://stackoverflow.com/questions/11632308/empty-nsmutablearray-not-sure-why) – Vladimir