#import <UIKit/UIKit.h> #import "AppDelegate.h" #import "Person.h" extern void _objc_autoreleasePoolPrint(); int main(int argc, char * argv[]) { @autoreleasepool { Person *p = [Person new]; Person __weak *p2 = p; NSLog(@"%@", p2); _objc_autoreleasePoolPrint(); // return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); } }
结果是这样的:
$ clang -rewrite-objc -fobjc-arc -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.0.sdk main.m /var/folders/t0/nty3j9vx1rn8786q_tpclydc0000gn/T/main-2fe2fd.mi:46509:31: error: cannot create __weak reference because the current deployment target does not support weak references Person __attribute__((objc_ownership(weak))) *p2 = p; ^ 1 error generated.
求解答
付费偷看金额在0.1-10元之间
__Weak不是应该在类名前面吗?
一周热门 更多>