NSObject autoreleasedCopy
I got tired of typing [[something copy] autorelease]. Too many brackets for such a basic operation.
And Yes, I know it violates the naming rules - somehow I can’t see any confusion arising with the “autoreleased” prefix.
-------------- Interface -------------
(HKNSObjectAutoreleasedCopy.h)
#import <Foundation/Foundation.h>
@interface NSObject(AutoreleasedCopy)
- (id) autoreleasedCopy;
- (id) autoreleasedMutableCopy;
@end
-------------- Implementation -------------
#import "HKNSObjectAutoreleasedCopy.h"
@implementation NSObject(AutoreleasedCopy)
- (id) autoreleasedCopy
{
return [[self copy] autorelease];
}
- (id) autoreleasedMutableCopy
{
return [[self mutableCopy] autorelease];
}
@end
• While fact-based, the contents of this website is 100% opinion • All advertisements Selected By Google Ad Sense • Your Mileage May Vary • Void Where Prohibited • Do Not Try This At Home • Don’t Be An Idiot •