ER: Add -[NSMutableArray setArray:copyItems:]

Originator:quinntaylor
Number:rdar://9998142 Date Originated:2011-08-22
Status:Open Resolved:
Product:Foundation Product Version:X
Classification:Enhancement Reproducible:Not Applicable
 
It would be really nice to have -[NSMutableArray setArray:copyItems:] to fill the gap between -[NSArray initWithArray:copyItems:] and -[NSMutable setArray:]. It's a pretty straightforward method, and could replace code that is inconvenient to write. (I've added it as a category, but would love to have it as API.)

- (void) setArray:(NSArray*)array copyItems:(BOOL)flag
{
	if (flag) {
		[self removeAllObjects];
		for (id object in array) {
			[self addObject:[[object copy] autorelease]];
		}
	} else {
		[self setArray:array];
	}
}

I imagine that if implemented internally, one could get slightly higher performance through more intelligent memory management of internal structures than would be possible for third-party developers.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!