Array copying and deleting
I have setup NSCopying and I can copy an array successfully.
theArray = [[NSMutableArray alloc] initWithArray:results.availableData
copyItems:YES];
When I am finished with theArray and all its data is junk I would like开发者_如何学编程 to get another fresh copy of the data from results.availableData array.
Whats the best and safest way to do this?
Should i
[theArray release];
theArray = [[NSMutableArray alloc] initWithArray:results.availableData
copyItems:YES];
So release theArray then alloc and init it again?
Many Thanks -Code
How about simply:
[theArray setArray: [[NSArray alloc] initWithArray: results.availableData
copyItems: YES] autorelease]];
And be done with it.
精彩评论