- (void)currentImageOnServer {
NSURL *JSONLocation = [NSURL URLWithString:@"http://mywebsite.com/Calendar/dirList.php"];
NSString *pictureLocation = [NSString stringWithFormat:@"http://mywebsite.com/Calendar/"];
[[[NSURLSession sharedSession] dataTaskWithURL:JSONLocation
completionHandler:^(NSData *JSONdata, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@ is the error code for currentImageOnServer", error);
}
// Process Data
NSError *jsonParsingError = nil;
NSArray *filesInDirectory = [NSJSONSerialization JSONObjectWithData:JSONdata
options:0
error:&jsonParsingError];
for (NSDictionary *dictionary in filesInDirectory) { NSString *fileName = dictionary[@"name"];
if ([[fileName pathExtension] isEqualToString: @"png"]) {
NSString *imagePath = [pictureLocation stringByAppendingPathComponent:[NSString urlEncodedString:fileName]];
calendarFileNameOnServer = fileName;
imageURL = imagePath;
NSLog(@"imageURL is %@", imageURL);
dispatch_async(dispatch_get_main_queue(), ^{
currentImageOnServerString = fileName;
[self runTheFileComparison];
NSLog(@"Dictionary Deal finished, calendarFileNameOnServer is now %@", calendarFileNameOnServer);
});
}
}
}] resume];
serverAlreadyChecked = YES;
}
Comments
0 B
|👍
/👎