我的数组有以下数据。我想搜索电子邮件ID和密码文本字段是否与数组值匹配。如果它们匹配,则用户可以登录其他无效凭证消息被警告。请帮帮我。
2014-01-03 12:08:20.909 Appify[542:11303] (
{
EmailId="sarika@gmail.com";password=sarika;
},
{
EmailId="kalyan@gmail.com";password=kalyan;
},
{
EmailId="kalyan@gmail.com";password=kalyan;
}
)
答案 0 :(得分:1)
try iterating through your array and find if username and password matches with the textfield data
For( NSDictionary *data in myArray)
{
if([emailtextField.text isEqualtoString:[data objectForKey:@"EmailId"]] && [passwordtextField.text isEqualtoString:[data objectForKey:@"password"]]){
//Login
break;
}
else{
// Not Logged in
}
}
答案 1 :(得分:0)
试试这个:
NSMutableDictionary *dict=[[NSMutableDictionary alloc]init];
[dict setValue:emailTextField.text forKey:@"email"];
[dict setValue:passwordTextField.text forKey:@"password"];
if([myarray containsObject:dict]){
//login
}else{
//dont login
}
答案 2 :(得分:0)
Appify[542:11303] (
{
EmailId="sarika@gmail.com";password=sarika;
},
{
EmailId="kalyan@gmail.com";password=kalyan;
},
{
EmailId="kalyan@gmail.com";password=kalyan;
}
)
密码不是nsstring类型,实际上是您的数据:
Appify[542:11303] (
{
EmailId="sarika@gmail.com";password="sarika";
},
{
EmailId="kalyan@gmail.com";password="kalyan";
},
{
EmailId="kalyan@gmail.com";password="kalyan";
}
)
检查您的数据