Skip to content

Instantly share code, notes, and snippets.

Peter Molnar petermolnar-hu

Block or report user

Report or block petermolnar-hu

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@petermolnar-hu
petermolnar-hu / PMODownloader.m
Created Jan 26, 2017
PMODownloader.m - Block based solution
View PMODownloader.m
#import "PMODownloader.h"
#import "PMODownloadNotifications.h"
@implementation PMODownloader
#pragma mark - Public API / Protocol implementation
- (void)downloadDataFromURL:(nonnull NSURL *)url completionHander:(void(^_Nonnull)(NSData * _Nullable downloadedData))callback {
NSURLRequest *request = [NSURLRequest requestWithURL:url];
@petermolnar-hu
petermolnar-hu / PMODownloader.h
Created Jan 26, 2017
PMODownloader.h - Block based solution
View PMODownloader.h
#import <Foundation/Foundation.h>
@interface PMODownloader : NSObject
//1
/**
The download method, which triggers the download from the parameter url, and executes the passed block in case of the succesful download.
@param url the URL of the downloadable resource
@param callback the callback block, which will be executed with succesfull download
@petermolnar-hu
petermolnar-hu / PMOPictureController.m
Created Jan 26, 2017
PMOPictureController.m - Block based solution
View PMOPictureController.m
#import "PMOPictureController.h"
#import "PMODownloader.h"
#import "PMOPictureWithURL.h"
#import "PMODownloadNotifications.h"
//1
typedef void (^DownloadCallBack)(NSData *);
@interface PMOPictureController()
@petermolnar-hu
petermolnar-hu / PMOPictureController.h
Created Jan 26, 2017
PMOPictureController.h - Block based solution
View PMOPictureController.h
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@interface PMOPictureController : NSObject
/**
The designated initializer, the picture's url is mandatory to pass.
@param url The picture full url, as NSURL
View NonNull_Nullable.h
@property (weak, nonatomic, nullable) id <PMOProgressDelegate> progressDelegate;
@property (unsafe_unretained, nonatomic) BOOL isAllModelParsed;
- (nullable instancetype)initWithModelControllers:(nullable NSArray <PMODrawModelController *>*) models NS_DESIGNATED_INITIALIZER;
- (nullable instancetype)init NS_UNAVAILABLE;
- (void)startPopulateDrawNumbersWithCompletionHandler:(void (^_Nonnull)(BOOL wasSuccessfull, NSArray <NSNumber*>* _Nullable numbers))callback;
@petermolnar-hu
petermolnar-hu / myObject.m
Created Jan 12, 2017
myObject.m - With convenience initializer
View myObject.m
@interface MyObject()
@property (nonatomic) BOOL isNightMode
@property (strong, nonatomic) MyOtherObject *theObjectDoingSomethingElse
@end
@implementation MyObject
#pragma mark - Initializers
//2
- (instancetype)initWithTheOtherObjectDoingSomethingElse:(MyOtherObject *)alreadyExisitingObject isNightModeOn:(BOOL)isNightMode {
@petermolnar-hu
petermolnar-hu / myObject.h
Created Jan 12, 2017
myObject.h - With convenience initilizer
View myObject.h
@interface MyObject : NsObject
//1
- (instancetype)initWithTheOtherObjectDoingSomethingElse:(MyOtherObject *)alreadyExisitingObject isNightModeOn:(BOOL)isNightMode NS_DESIGNATED_INITIALIZER;
/**
Removing the default initalize
*/
- ( instancetype)init NS_UNAVAILABLE;
@petermolnar-hu
petermolnar-hu / myObject.m
Last active Jan 12, 2017
myObject implementation
View myObject.m
@interface MyObject()
@property (nonatomic) BOOL isNightMode
@property (strong, nonatomic) MyOtherObject *theObjectDoingSomethingElse
@end
@implementation MyObject
#pragma mark - Initializers
//2
- (instancetype)initWithTheOtherObjectDoingSomethingElse:(MyOtherObject *)alreadyExisitingObject isNightModeOn:(BOOL)isNightMode {
@petermolnar-hu
petermolnar-hu / myObject.h
Last active Jan 12, 2017
myObject Header
View myObject.h
@interface MyObject : NsObject
//1
- (instancetype)initWithTheOtherObjectDoingSomethingElse:(MyOtherObject *)alreadyExisitingObject isNightModeOn:(BOOL)isNightMode NS_DESIGNATED_INITIALIZER;
/**
Removing the default initalizer
*/
- (nullable instancetype)init NS_UNAVAILABLE;
@end
@petermolnar-hu
petermolnar-hu / myObject.m
Created Jan 12, 2017
myObject - A better approach
View myObject.m
MyObject *myObject =[[MyObject alloc] initWithTheOtherObjectDoingSomethingElse:alreadyExisitingObject
isNightModeOn:isNightMode];
You can’t perform that action at this time.