Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- NSString *urlstring=[NSString stringWithFormat:@"http://demo.talentclouds.in/API/LoginHandler.asmx/Login?username=acet@acet.in&password=123={"username":"%@","password":"%@"}",self.userid.text,
- self.pwd.text];
- NSLog(@"url==>%@",urlstring);
- NSURL *addurl = [[NSURL alloc]initWithString:[urlstring stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLFragmentAllowedCharacterSet]]];
- NSData *apiData = [NSData dataWithContentsOfURL:addurl];
- NSLog(@"%@",apiData);
- NSError *error = nil;
- if(apiData==nil)
- {
- UIAlertController *alert = [UIAlertController alertControllerWithTitle:@" Server Error Meanwhile check your internet.." message:[error localizedDescription] preferredStyle:UIAlertControllerStyleAlert];
- UIAlertAction *defaultAction = [UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:nil];
- [alert addAction:defaultAction];
- [self presentViewController:alert animated:YES completion:nil];
- }
- else
- {
- apiDictionary = [NSJSONSerialization JSONObjectWithData:apiData options:kNilOptions error:&error];
- NSLog(@"%@",apiDictionary);
- username =[NSString stringWithFormat:@"%@",[apiDictionary valueForKey:@"username"]];
- NSLog(@"%@",username);
- password =[NSString stringWithFormat:@"%@",[apiDictionary valueForKey:@"password"]];
- NSLog(@"%@",password);
- message=[NSString stringWithFormat:@"%@",[apiDictionary valueForKey:@"message"]];
- NSLog(@"%@",message);
- response=[NSString stringWithFormat:@"%@",[apiDictionary valueForKey:@"response"]];
- NSLog(@"%@",response);
- if([response isEqualToString:@"success"])
- {
- [[NSUserDefaults standardUserDefaults]setObject:username forKey:@"USERNAME"];
- [[NSUserDefaults standardUserDefaults]setObject:password forKey:@"PASSWORD"]; [[NSUserDefaults standardUserDefaults]synchronize];
- login1ViewController *homeVC=[self.storyboard instantiateViewControllerWithIdentifier:@"StudentViewController"];
- [self.navigationController pushViewController:homeVC animated:YES];
- // _singleton.AutomaticLogin=@"1";
- UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Talent Cloud" message:message preferredStyle:UIAlertControllerStyleAlert];
- UIAlertAction *defaultAction = [UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:nil];
- [alert addAction:defaultAction];
- [self presentViewController:alert animated:YES completion:nil];
- }
- else
- {
- UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Talent Cloud" message:@"Please Enter username and password" preferredStyle:UIAlertControllerStyleAlert];
- UIAlertAction *defaultAction = [UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:nil];
- [alert addAction:defaultAction];
- [self presentViewController:alert animated:YES completion:nil];
- }
- }
Add Comment
Please, Sign In to add comment