Project

General

Profile

Actions

RemoveTable Objective-C

-(void)removeSynchrnizedTable:(nonnull NSString*)tableName error:(NSError * _Nullable * _Nullable)error{
    NSString *requestUrlString = [NSString stringWithFormat:@"%@/RemoveTable/%@", _serverURL, tableName];
    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 4 years ago · 1 revisions

Go to top