字典不可以传空值

来源:互联网 发布:什么什么知什么成语 编辑:程序博客网 时间:2024/04/30 02:44
***-[__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}; }
0 0