美文网首页
Objective-C warning Method overr

Objective-C warning Method overr

作者: zmjchuan | 来源:发表于2016-10-02 17:44 被阅读39次
    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

    相关文章

      网友评论

          本文标题:Objective-C warning Method overr

          本文链接:https://www.haomeiwen.com/subject/zludyttx.html