獲取數據我有一個RegistrationController
屏幕存儲email-id
,password
,DOB
,Height
,Weight
和logininController
屏幕匹配email-id
和password
到登錄的目的。如何從plist中的標籤
現在,在某些third
屏幕我,如果我在字符串存儲在與LoginViewController
的email-id
和password
值從登錄的用戶,以顯示它的label.now的plist中只獲取Height
,Weight
並調用它在新的屏幕..如果它可以解決那麼如何從同一個的plist中獲取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");
}
}
}
愛你的暱稱。 ^^ – Peres