Project

General

Profile

CommitSync Objective-C » History » Version 1

Tomek Dziemidowicz, 2019-07-18 09:00 PM

1 1 Tomek Dziemidowicz
h1. CommitSync Objective-C
2
3
<pre><code class="objc">
4
-(void)commitSynchronization:(NSNumber*)syncId error:(NSError **)error{
5
    NSString *requestUrlString = [NSString stringWithFormat:@"%@/CommitSync/%@", _serverURL, syncId];
6
    NSURL *requestURL = [NSURL URLWithString:requestUrlString];
7
    NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
8
9
    [request setURL:requestURL];
10
    [request setHTTPMethod:@"GET"];
11
12
    NSHTTPURLResponse *response;
13
14
    NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:error];
15
16
    if(!*error){
17
        switch (response.statusCode) {
18
            case 200:
19
                break;
20
            default:
21
                *error = [NSError errorWithDomain:@"com.sqlite-sync" code:0 userInfo:[NSDictionary dictionaryWithObject:[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] forKey:NSLocalizedDescriptionKey]];
22
                break;
23
        }
24
    }
25
}
26
</code></pre>
Go to top