Project

General

Profile

Actions

CommitSync Objective-C

-(void)commitSynchronization:(NSNumber*)syncId error:(NSError **)error{
    NSString *requestUrlString = [NSString stringWithFormat:@"%@/CommitSync/%@", _serverURL, syncId];
    NSURL *requestURL = [NSURL URLWithString:requestUrlString];
    NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];

    [request setURL:requestURL];
    [request setHTTPMethod:@"GET"];

    NSHTTPURLResponse *response;

    NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:error];

    if(!*error){
        switch (response.statusCode) {
            case 200:
                break;
            default:
                *error = [NSError errorWithDomain:@"com.sqlite-sync" code:0 userInfo:[NSDictionary dictionaryWithObject:[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] forKey:NSLocalizedDescriptionKey]];
                break;
        }
    }
}

Updated by Tomek Dziemidowicz over 5 years ago · 1 revisions

Go to top