Actions
AddTable Objective-C¶
-(void)addSynchrnizedTable:(nonnull NSString*)tableName error:(NSError * _Nullable * _Nullable)error{
NSString *requestUrlString = [NSString stringWithFormat:@"%@/AddTable/%@", _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 5 years ago · 1 revisions
Go to top