字典不可以传空值

***-[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[0]

字典传空值报错
字典传值前加入判断
如用户名密码textfield为空

UITextField *userName = (UITextField *)[self.xxxXibView viewWithTag:1];

UITextField *psw = (UITextField *)[self.xxxXibView viewWithTag:2];

if (userName.text != nil && psw.text != nil){

    NSDictionary *dict = @{@"UserName": userName.text, @"Password": psw.text}; 
}
    原文作者:Dean
    原文地址: https://segmentfault.com/a/1190000000652529
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞