redribben

what happened

Feb 6th, 2015
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 KB | None | 0 0
  1. - (void)currentImageOnServer {
  2. NSURL *JSONLocation = [NSURL URLWithString:@"http://radiolight.us/Calendar/dirList.php"];
  3. NSString *pictureLocation = [NSString stringWithFormat:@"http://radiolight.us/Calendar/"];
  4.  
  5. [[[NSURLSession sharedSession] dataTaskWithURL:JSONLocation
  6. completionHandler:^(NSData *JSONdata, NSURLResponse *response, NSError *error) {
  7. NSLog(@"%@ is the error code for currentImageOnServer", error);
  8. // Process Data
  9. NSError *jsonParsingError = nil;
  10. NSArray *filesInDirectory = [NSJSONSerialization JSONObjectWithData:JSONdata
  11. options:0
  12. error:&jsonParsingError];
  13. for (NSDictionary *dictionary in filesInDirectory) { NSString *fileName = dictionary[@"name"];
  14. if ([[fileName pathExtension] isEqualToString: @"png"]) {
  15. NSString *imagePath = [pictureLocation stringByAppendingPathComponent:fileName];
  16. nameOfFile = fileName;
  17.  
  18. imageURL = imagePath;
  19. NSLog(@"imageURL is %@", imageURL);
  20. dispatch_async(dispatch_get_main_queue(), ^{
  21. currentImageOnServerString = fileName;
  22. [self runTheFileComparison];
  23. NSLog(@"Dictionary Deal finished, nameOfFile is now %@", nameOfFile);
  24. });
  25. }
  26. }
  27. }] resume];
  28. serverAlreadyChecked = YES;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment