- (void)loadZip {
NSString *mainUrl = [self.server stringByAppendingString:@"/files/YOURZIP.zip"];
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:mainUrl]];
[NSURLConnection sendAsynchronousRequest:request
queue:[NSOperationQueue mainQueue]
completionHandler:^(NSURLResponse *respons,
NSData *dat,
NSError *connectionError) {
if (!connectionError) {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *appFile = [documentsDirectory stringByAppendingPathComponent:@"YOURZIP.zip"];
NSError *error;
BOOL flag = [dat writeToFile:appFile options:NSDataWritingAtomic error:&error];
if (flag) {
NSLog(@"You cool");
} else {
NSLog(@"%@", error.localizedDescription);
[self loadZip];
}
} else {
NSLog(@"%@",[connectionError localizedDescription]);
}
}];
}