redribben icon

what happened

redribben | PRO | 02/06/15 07:27:50 AM UTC | 0 ⭐ | 507 👁️ | Never ⏰ | []
text |

2.15 KB

|

None

|

0 👍

/

0 👎

- (void)currentImageOnServer {
    NSURL *JSONLocation = [NSURL URLWithString:@"http://radiolight.us/Calendar/dirList.php"];
    NSString *pictureLocation = [NSString stringWithFormat:@"http://radiolight.us/Calendar/"];
     [[[NSURLSession sharedSession] dataTaskWithURL:JSONLocation
                                 completionHandler:^(NSData *JSONdata, NSURLResponse *response, NSError *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:fileName];
                                             nameOfFile = fileName;
                                              imageURL = imagePath;
                                             NSLog(@"imageURL is %@", imageURL);
                                             dispatch_async(dispatch_get_main_queue(), ^{
                                                 currentImageOnServerString = fileName;
                                                 [self runTheFileComparison];
                                                 NSLog(@"Dictionary Deal finished, nameOfFile is now %@", nameOfFile);
                                             });
                                         }
                                     }
                                 }] resume];
    serverAlreadyChecked = YES;
}

Comments