美文网首页selector
NS_AVAILABLE_IOS与NS_DEPRECATED_I

NS_AVAILABLE_IOS与NS_DEPRECATED_I

作者: 管乐_VICTOR | 来源:发表于2016-09-18 20:02 被阅读3798次

    在iOS的API中,我们经常会看到

    // Returns interface orientation masks.
    - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation NS_AVAILABLE_IOS(6_0) __TVOS_PROHIBITED;
    
    // The rotating header and footer views will slide out during the rotation and back in once it has completed.
    - (nullable UIView *)rotatingHeaderView NS_DEPRECATED_IOS(2_0,8_0, "Header views are animated along with the rest of the view hierarchy") __TVOS_PROHIBITED;     // Must be in the view hierarchy. Default returns nil.
    - (nullable UIView *)rotatingFooterView NS_DEPRECATED_IOS(2_0,8_0, "Footer views are animated along with the rest of the view hierarchy") __TVOS_PROHIBITED;     // Must be in the view hierarchy. Default returns nil.
    
    @property(nonatomic,readonly) UIInterfaceOrientation interfaceOrientation NS_DEPRECATED_IOS(2_0,8_0) __TVOS_PROHIBITED;
    
    // Notifies when rotation begins, reaches halfway point and ends.
    - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration NS_DEPRECATED_IOS(2_0,8_0, "Implement viewWillTransitionToSize:withTransitionCoordinator: instead") __TVOS_PROHIBITED;
    - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation NS_DEPRECATED_IOS(2_0,8_0) __TVOS_PROHIBITED;
    
    

    其含义分别为:NS_AVAILABEL_IOS(6_0)表示,自IOS6.0开始支持该方法,若在IOS6.0之前的版本使用该函数,则会导致 Crash;NS_DEPRECATED_IOS(2_0,3_0)表示该函数只能在IOS2.0 和 IOS3.0之间使用,是已被废弃的函数,但并不是说在IOS3.0之后不能使用该函数,是可以使用,但也需要考虑找其他替代方法了
    另外,还有 NS_DEPRECATED(10_6,10_9,2_0,7_0)这种写法,为自mac10.6和ios2.0引入,在mac10.9和ios7.0被废弃

    参考文章:http://blog.csdn.net/sanjiewang/article/details/38559909

    相关文章

      网友评论

        本文标题:NS_AVAILABLE_IOS与NS_DEPRECATED_I

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