我想从2 NSArray添加对象到NSMutableArray.我不知道这个.
我的代码:
@interface ViewController : UITableViewController { NSArray *animal; NSArray *color; NSMutableArray *all; } @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; animal = [[NSArray alloc]initWithObjects:@"Lion",@"Tiger",@"Dog",@"Cat",@"Sheep",@"Wolf",nil]; color = [[NSArray alloc]initWithObjects:@"Blue",@"Red",@"Yellow",@"Green",@"Black",nil]; all = ??? ; //how to add object from animal and color array in all }
解决方法
你可以从
NSMutableArray班使用
addObjectsFromArray:
all = [[NSMutableArray alloc]init]; [all addObjectsFromArray:animal]; [all addObjectsFromArray:color];