NSArray arrayWithArray
Creates and returns an array containing the objects in another given array.
+ (id)arrayWithArray:(NSArray *)anArray
Parameters
anArray
An array.
Return Value of [NSArray arrayWithArray]
An array containing the objects in anArray.
NSArray arrayWithArray example.
// Both resulting arrays are immutable and won't be retained
NSArray* immutableArray = [[[NSArray alloc] initWithArray:mutableArray] autorelease];
NSArray* immutableArray = [NSArray arrayWithArray:mutableArray];
NSArray* immutableArray = [[mutableArray copy] autorelease];
NSArray* immutableArray = [[[NSArray alloc] initWithArray:mutableArray] autorelease];
NSArray* immutableArray = [NSArray arrayWithArray:mutableArray];
NSArray* immutableArray = [[mutableArray copy] autorelease];
Example of [NSArray arrayWithArray].
NSMutableArray *tableData = [NSMutableArray arrayWithArray:[myDict allValues]];
[tableData retain];
// TableData Sort Code Here
[tableData retain];
// TableData Sort Code Here
NSArray arrayWithArray example.
- (NSArray)getVerseList
{
NSMutableArray *l = [[NSMutableArray
alloc]initWithCapacity:[verses count]];
{
unsigned int count = 0;
for (count = 0;count < [verses count];count++)
{
[l addObject:[[NSString alloc] initWithFormat:@"%i",
count]];
}
}
NSArray *newArr = [[NSArray alloc] arrayWithArray:l ];
[l release];
return newArr;
}
{
NSMutableArray *l = [[NSMutableArray
alloc]initWithCapacity:[verses count]];
{
unsigned int count = 0;
for (count = 0;count < [verses count];count++)
{
[l addObject:[[NSString alloc] initWithFormat:@"%i",
count]];
}
}
NSArray *newArr = [[NSArray alloc] arrayWithArray:l ];
[l release];
return newArr;
}