开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜