登录从Plist检查凭据 [英] SignIn check Credentials from Plist

查看:76
本文介绍了登录从Plist检查凭据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 plist 数组标题和 item0 item1 item2 是存储我app.now的标题和密码的字典。我想检查登录过程

I have a plist with Array title and item0,item1,item2 is dictionary to store title and password of my app.now i want to check for signin process


现在我要检查当我按下提交按钮登录时,应该匹配传递和项目。我尝试下面的代码,但xcode崩溃

now i Want to check for pass and items should be matched when i press submit button to login.i Tried the below code but xcode crashes

-(void)authenticateCredentials 
{ 
NSMutableArray *plistArray = [NSMutableArray arrayWithArray:[self readFromPlist]]; 

for (int i = 0; i< [plistArray count]; i++) 
{ 
 if ([[[plistArray   objectAtIndex:i]objectForKey:@"pass"]isEqualToString:emailTextFeild.text] && [[[plistArray objectAtIndex:i]objectForKey:@"title"]isEqualToString:passwordTextFeild.text]) 
{ 
NSLog(@"Correct credentials"); 
} 

 } 
 }

-(NSArray*)readFromPlist
 {
   NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
  NSUserDomainMask, YES); 
  NSString *documentsDirectory = [documentPaths objectAtIndex:0];
 NSString *documentPlistPath = [documentsDirectory stringByAppendingPathComponent:@"XYZ.plist"];

   NSDictionary *dict = [NSDictionary dictionaryWithContentsOfFile:documentPlistPath];

   NSArray *valueArray = [dict objectForKey:@"title"];

   return valueArray;

 }

xcode崩溃..请检查 - (void)authenticateCredentials 我哪里不对?

the xcode gets crashs ..please check in -(void)authenticateCredentials where i am incorrect?

编辑
当我选择<$ c时崩溃$ c>提交按钮,它在nslog中输出正确但崩溃然后,错误

"Edit" Crash when I select the submit button,Its giving output in nslog correct but crash then , with errorr

 2012-12-07 16:52:54.025 NavTutorial[3029:f803] emailEntry: emailemail@gmail.com
 2012-12-07 16:52:54.057 NavTutorial[3029:f803] passwordEntry: abcd
 2012-12-07 16:52:54.081 NavTutorial[3029:f803] Correct credentials
 2012-12-07 16:52:54.081 NavTutorial[3029:f803] Correct credentials
 2012-12-07 16:52:54.082 NavTutorial[3029:f803] -[__NSCFString objectForKey:]:     unrecognized selector sent to instance 0x68e9c30
 2012-12-07 16:52:54.083 NavTutorial[3029:f803] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString objectForKey:]: unrecognized selector sent to instance 0x68e9c30'
 *** First throw call stack:
(0x14d7052 0x11c2d0a 0x14d8ced 0x143df00 0x143dce2 0x3e71 0x14d8ec9 0x3735c2 0x37355a 0x418b76 0x41903f 0x417e22 0x39893f 0x398c56 0x37f384 0x372aa9 0x1bcdfa9 0x14ab1c5 0x1410022 0x140e90a 0x140ddb4 0x140dccb 0x1bcc879 0x1bcc93e 0x370a9b 0x252d 0x24a5 0x1)
terminate called throwing an exception


推荐答案

我实际上是我的错..代码在代码中所以一次又一次地执行..然后崩溃......但是当我把返回退出 for 循环时。 ..的工作正常...小而强大的错误。

I was my fault actually .. the code is in code so executes again and again ..then crashes...but when i put Return to exit from the for loop ...its works fine...small but powerful mistake.

这篇关于登录从Plist检查凭据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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