i had a Plist file which contains username and password.
how to fetch data from Plist and Validate with user input values when ever the submit button is clicked.
after submit button is pressed. if user input data matches with data in Plist. it should show Login successful and displays Profile data in Another View controller.
in Objective-C
You can try
Swift
// force unwrapped to assure existence of data
let path = Bundle.main.path(forResource: "fileName", ofType: "plist")
let dic = NSDictionary(contentsOfFile: path) as! [String:String]
self.name = dic["username"] as! String
self.pass = dic["password"] as! String
when submit
check
if username.text == name && password.text == pass {
// success
}
Objective-C
NSDictionary *mainDictionary = [NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"fileName" ofType:@"plist"]];
NSString *name = mainDictionary[@"username"];
NSString *pass = mainDictionary[@"password"];
if ([username.text isEqualToString:name] && [password.text isEqualToString:pass]) {
// success
}