【发布时间】:2012-10-15 09:19:13
【问题描述】:
理解 Obj-C 的记忆体及其一些概念仍有一些困难。
所以我的主类包含一个NSMutableArray,其中包含一些角色及其武器列表。是这样的:
在主类.h
@property (nonatomic, retain) NSMutableArray *players;
在 Main class.m 的 init 中
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.
}
这里的武器列表总是空的。怎么了?
【问题讨论】:
标签: objective-c nsmutablearray nsarray