I have three NSArray
objects. I need to add all objects for this array to NSArray
that is called allMyObjects.
Have NSArray
standard solution to make it for example via initialization method or do I need make custom method to retrieve all objects from other arrays and put all retrieved objects to my allMyObjects array?
Don't know if this counts as a sufficiently simple solution to your problem, but this is the straight forward way to do it (as alluded to by other answerers, too):
NSMutableArray *allMyObjects = [NSMutableArray arrayWithArray: array1];
[allMyObjects addObjectsFromArray: array2];
[allMyObjects addObjectsFromArray: array3];
once see this one ,
NSArray *newArray=[[NSArray alloc]initWithObjects:@"hi",@"how",@"are",@"you",nil];
NSArray *newArray1=[[NSArray alloc]initWithObjects:@"hello",nil];
NSArray *newArray2=[[NSArray alloc]initWithObjects:newArray,newArray1,nil];
NSString *str=[newArray2 componentsJoinedByString:@","];
NSCharacterSet *doNotWant = [NSCharacterSet characterSetWithCharactersInString:@"()\n "];
str = [[str componentsSeparatedByCharactersInSet:doNotWant] componentsJoinedByString: @""];
NSArray *resultArray=[str componentsSeparatedByString:@","];
NSLog(@"%@",resultArray);
O/P:-
(
hi,
how,
are,
you,
hello
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With