This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "PMOPictureController.h" | |
#import "PMODownloader.h" | |
#import "PMOPictureWithURL.h" | |
//1 | |
#define CLASS_NAME NSStringFromClass([self class]) | |
#define INIT_EXCEPTION_MESSAGE [NSString stringWithFormat:@"Use [[%@ alloc] initWithPictureURL:]",CLASS_NAME] | |
@interface PMOPictureController() | |
//2 | |
/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef PMODownloadNotifications_h | |
#define PMODownloadNotifications_h | |
static NSString *const _Nonnull PMODownloadWasSuccessful = @"PMODownloadWasSuccessful" | |
static NSString *const _Nonnull PMODownloadFailed = @"PMODownloadFailed" | |
#endif /* PMODownloadNotifications_h */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "PMODownloader.h" | |
#import "PMODownloadNotifications.h" | |
@implementation PMODownloader | |
#pragma mark - Public API | |
- (void)downloadDataFromURL:(NSURL *)url { | |
//1 | |
NSURLRequest *request = [NSURLRequest requestWithURL:url]; | |
NSURLSession *session = [NSURLSession sharedSession]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
@interface PMODownloader : NSObject | |
/** | |
Downloading and giving back the raw data result from the url. | |
@param url the source url | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "PMOPictureController.h" | |
#import "PMODownloader.h" | |
#import "PMOPictureWithURL.h" | |
//1 | |
#import "PMODownloadNotifications.h" | |
#define CLASS_NAME NSStringFromClass([self class]) | |
#define INIT_EXCEPTION_MESSAGE [NSString stringWithFormat:@"Use [[%@ alloc] initWithPictureURL:]",CLASS_NAME] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <XCTest/XCTest.h> | |
#import "PMOPictureController.h" | |
#import "PMODownloadNotifications.h" | |
@interface PMOPictureControllerTests : XCTestCase | |
@property (strong, nonatomic) PMOPictureController *pictureController; | |
@end | |
@implementation PMOPictureControllerTests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSDate *today = [NSDate date]; | |
NSDateComponents *dayComponent = [[NSDateComponents alloc] init]; | |
dayComponent.day = 1; | |
NSCalendar *theCalendar = [NSCalendar currentCalendar]; | |
NSDate *tomorrow = [theCalendar dateByAddingComponents:dayComponent toDate:today options:0]; | |
dayComponent.day = -1; | |
NSDate *yesterday = [theCalendar dateByAddingComponents:dayComponent toDate:today options:0]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
@interface PMODownloader : NSObject | |
//1 | |
/** | |
Property to store the downloaded data in NSData format | |
*/ | |
@property (strong, nonatomic, nullable) NSData *downloadedData; | |
/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "PMODownloader.h" | |
#import "PMODownloadNotifications.h" | |
@implementation PMODownloader | |
#pragma mark - Public API | |
- (void)downloadDataFromURL:(NSURL *)url { | |
NSURLRequest *request = [NSURLRequest requestWithURL:url]; | |
NSURLSession *session = [NSURLSession sharedSession]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "PMOPictureController.h" | |
#import "PMODownloader.h" | |
#import "PMOPictureWithURL.h" | |
#import "PMODownloadNotifications.h" | |
//1 | |
static void *DownloadedDataObservation = &DownloadedDataObservation; | |
@interface PMOPictureController() | |
//2 |