我有一个RegistrationController
屏幕来存储email-id
, password
, DOB
,Height
和屏幕来匹配Weight
和 登录目的。logininController
email-id
password
现在,在某些third
屏幕中,我必须仅从 登录用户的 plist 中获取 , 以将其显示在标签上。如果我将值Height
和in存储在字符串中并在新屏幕中调用它以匹配 if匹配然后给出, ..如果它更正,那么如何从同一 plist 中获取。Weight
email-id
password
LoginViewController
Height
Weight
Height
Weight
如何从字符串中存储的 plist 中获取?
这是我的代码:
-(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;
}
- (void)authenticateCredentials {
NSMutableArray *plistArray = [NSMutableArray arrayWithArray:[self readFromPlist]];
for (int i = 0; i< [plistArray count]; i++)
{
id object = [plistArray objectAtIndex:i];
if ([object isKindOfClass:[NSDictionary class]]) {
NSDictionary *objDict = (NSDictionary *)object;
if ([[objDict objectForKey:@"pass"] isEqualToString:emailTextFeild.text] && [[objDict objectForKey:@"title"] isEqualToString:passwordTextFeild.text])
{
NSLog(@"Correct credentials");
return;
}
NSLog(@"INCorrect credentials");
} else {
NSLog(@"Error! Not a dictionary");
}
}
}