NSArray is Immutable and ordered collection i.e you can not update if once its initialized while
NSMutableArray is Mutable and ordered collection i.e you can add more object as per your requirement
Example:
NSArray *arr1 = [[NSArray alloc]initWithObjects:@"Amit", @"Jai",@"Sudheer", nil];
NSLog(@"%@",arr1);
outPut :
Amit,
Jai,
Sudheer
)
[arr1 addObject:@"Kiran"]; if we try to do like this,we get build error as
No visible @interface for 'NSArray' declares the selector 'addObject':
NSMutableArray *Muarr1 = [[NSMutableArray alloc]initWithObjects:@"Amit", @"Jai",@"Sudheer", nil];
NSLog(@"%@",Muarr1);
outPut :
2013-05-02 11:34:46.226 FirstStoryBoardViewController[418:c07] (
Amit,
Jai,
Sudheer
)
[Muarr1 addObject:@"Kiran"];
NSLog(@"%@",Muarr1);
outPut :
2013-05-02 11:37:37.178 FirstStoryBoardViewController[458:c07] (
Amit,
Jai,
Sudheer,
Kiran
)
No comments:
Post a Comment