我收到以下警告,但我不知道从哪里开始,有什么想法吗?
NSObject+Be.m:36:3: [rewriter] it is not safe to remove an unused 'autorelease' message; its receiver may be destroyed immediately
NSObject+Be.m:35:40: [rewriter] NSInvocation's getReturnValue is not safe to be used with an object with ownership other than __unsafe_unretained
NSObject+Be.m:36:4: ARC forbids explicit message send of 'autorelease'
#import "NSObject+Be.h"
@interface BeProxy : NSProxy {
id target;
}
+ (BeProxy *)beProxyForClass:(Class)class;
- (void)forwardInvocation:(NSInvocation *)anInvocation;
- (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector;
@end
@implementation BeProxy
+ (BeProxy *)beProxyForClass:(Class)class {
BeProxy *beProxy = [BeProxy alloc];
beProxy->target = [class alloc];
return beProxy;
}
//
// We assume the method called is an init method. The return value
// may be a new value for self.
- (void)forwardInvocation:(NSInvocation *)anInvocation {
[anInvocation setTarget:target];
[anInvocation invoke];
id object;
[anInvocation getReturnValue:(void *)&object]; //HERE
[object autorelease]; //HERE
[self release];
}
- (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector {
return [target methodSignatureForSelector:aSelector];
}
@end
//
@implementation NSObject (Be)
+ (id)be {
return [BeProxy beProxyForClass:[self class]];
}
+ (id)beInit {
return [[[self class] new] autorelease];
}
- (id)beCopy {
return [[self copy] autorelease];
}
@end