我有一个plist
带有Array
标题和item0
,item1
的item2
字典来存储我的应用程序的标题和密码。现在我想检查登录过程
现在我想检查通过,当我按下提交按钮登录时,项目应该匹配。我尝试了下面的代码,但 xcode 崩溃
-(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
我不正确的地方?
“编辑”当我选择submit
按钮时崩溃,它在 nslog 中给出正确的输出但随后崩溃,并带有错误
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