Saturday, June 1, 2013

NSMutableArray addObjectsFromArray example in Objective C (iOS).


NSMutableArray addObjectsFromArray

Adds the objects contained in another given array to the end of the receiving array’s content.

- (void)addObjectsFromArray:(NSArray *)otherArray

Parameters of [NSMutableArray addObjectsFromArray]
otherArray
An array of objects to add to the end of the receiving array’s content.

NSMutableArray addObjectsFromArray example.
NSMutableArray *searchArray = [[NSMutableArray alloc] init];
for (NSDictionary *dictionary in searchedContactsFromTable)
{
       NSMutableArray *array = (NSMutableArray *)[[[dictionary objectForKey:@"fullName"] miutableCopy];
       [searchArray addObjectsFromArray:array];

}

Example of [NSMutableArray addObjectsFromArray].
NSMutableArray *array = [[NSMutableArray alloc] init];
NSMutableArray *searchArray = [[NSMutableArray alloc] init];
for (NSDictionary *dictionary in searchedContactsFromTable)
{
       [array addObject:[dictionary objectForKey:@"fullName"]];
       [searchArray addObjectsFromArray:array];

}

NSMutableArray addObjectsFromArray example.
NSMutableArray *objectsToAdd= [[NSMutableArray alloc] initWithObjects:@"one",@"two", nil];

NSMutableArray *myArray = [[NSMutableArray alloc] initWithObjects:objectsToAdd,nil];

self.list = [[NSMutableArray alloc] init];

[self.list addObjectsFromArray:myArray];

End of NSMutableArray addObjectsFromArray example article.