I'm very new to Objective C and mobile development. I want to perform a get and use the response outside this session, can anyone tell me how I can do this?
Now i got the error "Use of undeclared identifier 'username'
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
[request setURL:[NSURL URLWithString:url]];
[request setHTTPMethod:@"GET"];NSURLSession *session = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];
[[session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
NSString *requestReply = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
NSRange rangeUsername = [requestReply rangeOfString:@"<username>"];
NSString *username = [requestReply substringFromIndex:rangeUsername.location];
username = [username stringByReplacingOccurrencesOfString:@"<username>" withString:@""];
username = [username stringByReplacingOccurrencesOfString:@"</username>" withString:@""];
NSRange rangeDomain = [requestReply rangeOfString:@"<SIP_domain>"];
NSString *domain = [requestReply substringFromIndex:rangeDomain.location];
domain = [domain stringByReplacingOccurrencesOfString:@"<SIP_domain>" withString:@""];
domain = [domain stringByReplacingOccurrencesOfString:@"</SIP_domain>" withString:@""];
}] resume];
NSLog(@"Username: %@", username);
NSLog(@"Domain: %@", domain);