Thotz/Thotz.html
 

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