how to fetch data from Plist in Label

Posted by SameSung Vs Iphone on Stack Overflow See other posts from Stack Overflow or by SameSung Vs Iphone
Published on 2012-12-19T11:01:38Z Indexed on 2012/12/19 11:03 UTC
Read the original article Hit count: 157

Filed under:
|
|
|

I have a RegistrationController screen to store email-id ,password,DOB,Height,Weight and logininController screen to match email-id and password to log-in purpose.

Now In some third screen I have to fetch only the Height,Weight from the plist of the logged-in user to display it on the label.now if I Store the values of email-id and password in from LoginViewController in string and call it in the new screen to match if matches then gives Height,Weight ..if it corrects then how to fetch Height,Weight from the plist of the same one. how can i fetch from the stored plist in a string...

the code which i used to match in LoginController

-(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");
        }
    }
}

© Stack Overflow or respective owner

Related posts about iphone

Related posts about ios