Exemple de code
- (void)reqUserBalance:(NSString*)reward_scheme_id id:(NSString*)user_id success:(void (^)(id responseObject))success failure:(void (^)(id responseObject))failure{
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@reward/%@/user/%@/balance",URL_SERVER,reward_scheme_id,user_id]];
NSLog(@"%@",url);
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[request setValue:@"true" forHTTPHeaderField:@"Bypass"];
[NSURLConnection sendAsynchronousRequest:request
queue:[NSOperationQueue mainQueue]
completionHandler:^(NSURLResponse *response,
NSData *data, NSError *connectionError)
{
options:kNilOptions error:NULL];
if (data.length > 0 && connectionError == nil)
{
NSDictionary * userPoints = [NSJSONSerialization JSONObjectWithData:data
options:0
error:NULL];
NSString * points = [[userPoints objectForKey:@"points"] stringValue];
NSLog(@"%@",points);
[SecuritySetting sharedInstance].usearAvailablePoints = points;
}
}];
}