redribben icon

imageOnServer

redribben | PRO | 05/27/15 09:39:12 PM UTC | 0 ⭐ | 4536 👁️ | Never ⏰ | []
Objective C |

0 B

|

None

|

0 👍

/

0 👎

- (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

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎