Objective-C warning Method overr

2016-10-02  本文已影响39人  zmjchuan
In your .h files:

@interface MyClass : NSObject
- (instancetype)init NS_UNAVAILABLE;
@end
In .m files:

@interface MyClass ()
- (instancetype)init NS_DESIGNATED_INITIALIZER;
@end

@implementation MyClass
- (instancetype)init { @throw nil; }
@end

-(instancetype)init
{
    self = [super init];
    return self;
}

参考文章:

http://stackoverflow.com/questions/32741123/objective-c-warning-method-override-for-the-designated-initializer-of-the-superc

http://stackoverflow.com/questions/26185239/ios-designated-initializers-using-ns-designated-initializer

上一篇下一篇

猜你喜欢

热点阅读