Project

General

Profile

RemoveTable Objective-C » History » Version 1

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

1 1 Tomek Dziemidowicz
h1. RemoveTable Objective-C
2
3
<pre><code class="objc">
4
-(void)removeSynchrnizedTable:(nonnull NSString*)tableName error:(NSError * _Nullable * _Nullable)error{
5
    NSString *requestUrlString = [NSString stringWithFormat:@"%@/RemoveTable/%@", _serverURL, tableName];
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