自动释放问题

时间:2010-05-15 01:31:16

标签: iphone objective-c

如果已经被BObject对象使用,为什么NSArray会自动分配arrayWithObjects dealloc?在teory NSArray必须保持分配所有BObject的生命时间...

[[BObject alloc] initObjectName:@"oneObject" states:
   [NSArray arrayWithObjects:
    [[State alloc] initStateName:@"stand_front" singleImg:[NSArray arrayWithObjects:[UIImage imageNamed:@"front_1.png"], nil]],
    [[State alloc] initStateName:@"front_walking" frames:
     [NSArray arrayWithObjects:
      [UIImage imageNamed:@"front_1.png"],
      [UIImage imageNamed:@"front_2.png"],
      [UIImage imageNamed:@"front_3.png"],
      [UIImage imageNamed:@"front_4.png"],
      [UIImage imageNamed:@"front_5.png"],
      [UIImage imageNamed:@"front_6.png"],
      [UIImage imageNamed:@"front_7.png"],
      [UIImage imageNamed:@"front_8.png"], 
      nil] duration:0.8 repeat:0],
    nil]
   isSolid:TRUE];

2 个答案:

答案 0 :(得分:1)

BObject必须保留传递为states:

的数组

答案 1 :(得分:0)

BObject可能会复制数组,而不是保留它。