iphone - Objective-C initializing an NSArray vs NSMutableArray -


why work:

self.array = newarray; 

but doesn't:

[[self mutablearray] addobject:object]; 

meaning, why need init nsmutablearray work when don't have init nsarray?

edit: hops clearer guys.

interface:

@interface foo : uiviewcontroller {  }  @property (nonatomic, retain) nsarray *array; @property (nonatomic, retain) nsmutablearray *mutablearray;  @end 

implementation:

@implementation foo  @synthesize array; @synthesize mutablearray;  - (void)viewdidload {     [super viewdidload];     self.array = [class returninganarray];     [[self mutablearray] addobject:objectihaveomittedthecode]; }  @end 

self.array = newarray; 

in line, assigning created object self.array. so, you've no need create it.

[[self mutablearray] addobject:object]; 

but in line trying add object array not created actually. if don't create array, nil, , sending message nil won't take effect.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -