zoukankan      html  css  js  c++  java
  • iOS

    我们在些程序时会发现苹果里面有好多非常好的提示

    比如:

    1.每次SDK升级后 一些方法的方法已经过时了,这时候会给你提示描述该方法已经过期(作用:1.兼顾老版本 2.给开发者一个提示)

    2.有时候项目里面父类的方法没有重写 在控制台会给你提示

    3.可以穿多个参数的方法 比如UIAlertView 的创建方法里面最后一个参数可以传多个用...代替

    UIAlertView* alertView [[UIAlertView alloc]initWithTitle:<#(nullable NSString *)#> message:<#(nullable NSString *)#> delegate:<#(nullable id)#> cancelButtonTitle:<#(nullable NSString *)#> otherButtonTitles:<#(nullable NSString *), ...#>, nil]

    以上是我目前在项目里面遇到的

    应用场景:

    1.如果自己写的方法也已经过时了 要弃用了 如何给其他成员一个提示呢 ?

    //属性过时了的描述方法
    @property (nonatomic, copy) NSString *township __attribute((deprecated("该字段从v2.2.0版本起不再返回数据,建议您使用AMapSearchKit的逆地理功能获取."))); 
    
    //方法过时或不能用的描述
    
    + (NSString *)getWeiboAppSupportMaxSDKVersion __attribute__((deprecated));
    
    + (NSString *)getWeiboAppSupportMaxSDKVersion __attribute__((deprecated("这里面可以写描述哦")));
    
    //方法不能用的描述
    - (instancetype)init __attribute__((unavailable));
    
    
    //总结
    // 不管是方法还是属性的过期或不能用的提示格式是
     __attribute__((deprecated))
     __attribute__((deprecated("这个里面可以写描述哦当让也可以不写像上面那样")))

    2.字节写个父类其中有的方法想让子类去重写实现

    #pragma mark - must override methods
    
    - (void)handleChangeAlbum:(UIButton *)sender {
    
        NSAssert(NO, @"sub class should override");
    
    }
     
    
    - (NSString)handleAlbumListCellSelected:(NSNotification *)aNotify {
    
        NSAssert(NO, @"sub class should override");
        return nil;
    
    }

    3.想传多个参数用...代替  这个稍后再给方法

  • 相关阅读:
    每日签到
    手机刮刮卡
    js随机更换
    jquery实现input输入框实时输入触发事件代码
    webAPP前端必备知识
    让你分分钟学会 JS 闭包
    js获取url?后的参数
    js获取上传的文件名
    Javascript 中神奇的 this
    由浅入深完全掌握Ajax
  • 原文地址:https://www.cnblogs.com/junhuawang/p/6171026.html
Copyright © 2011-2022 走看看