I wrote a simple OC file to test a __weak reference
#import "Foundation/Foundation.h"
@interface Foo : NSObject
@property (nonatomic, assign) int a;
- (void)test;
@end
@implementation Foo
- (void)test
{
__weak typeof(self) weakSelf = self;
[weakSelf test];
}
@end
int main()
{
Foo* foo = [[Foo alloc] init];
foo.a = 3;
[foo test];
return 0;
}
Compiled with clang -rewrite-objc keke.m I got following error:
cannot create __weak reference because the current deployment target does not support weak references __attribute__((objc_ownership(weak))) typeof(self) weakSelf = self;
How could I set the depoly target directly in clang. I tried
clang -rewrite-objc -stdlib=libc++ -mmacosx-version-min=10.7 keke.m
but no luck.