在 NSPredicate 中组合两个条件 [英] Combining Two Conditions in NSPredicate

查看:55
本文介绍了在 NSPredicate 中组合两个条件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在NSPredicate 中组合两个条件?我正在使用以下语句,我想添加另一个条件,使用 AND 将密码与文本字段的内容进行比较:

How do you combine two conditions in NSPredicate? I am using the following statement and I would like to add another condition that compares the the password with the contents of a textfield using AND:

request.predicate = NSPredicate(format: "username = %@", txtUserName.text!)

推荐答案

试试这个

request.predicate = NSPredicate(format: "username = %@ AND password = %@", txtUserName.text!, txtPassword.text!)

这篇关于在 NSPredicate 中组合两个条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆