Hi i am beginner in iOS and in my project there is facility for users "ForGotPassword" request using NSURLConnection post request
For this i have written some code but that is not working and showing exception like
"This class is not key value coding-compliant for the key MedicaidId.'"
what did i do here wrong please help me
my code:-
- (void)viewDidLoad {
[super viewDidLoad];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@"my-url"]];
[request setHTTPMethod:@"POST"];
[request setValue:self.MedicalIdTxt.text forKey:@"MedicaidId"];
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:request delegate:self];
if (theConnection) {
NSLog(@"connected");
receivedData=[[NSMutableData alloc]init];
}
else {
NSLog(@"not connected");
}
}
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
[receivedData setLength:0];
}
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
[receivedData appendData:data];
NSString* responseString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSLog(@"response: %@",responseString);
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
NSLog(@"Succeeded! Received %lu data",(unsigned long)[receivedData length]);
NSString* responseString = [[NSString alloc] initWithData:receivedData encoding:NSUTF8StringEncoding];
NSLog(@"response: %@",responseString);
NSError *myError = nil;
NSDictionary *res = [NSJSONSerialization JSONObjectWithData:receivedData options:NSJSONReadingMutableLeaves error:&myError];
NSLog(@"final result is %@",res);
}