Skip to content

Instantly share code, notes, and snippets.

Avatar

Peter Molnar petermolnar-dev

View GitHub Profile
View BloodPressureClassifierDense.swift
class BloodPressureClassifier {
static func classifyBloodpessure(systolicValue: Int, diastoicValue: Int) -> BloodPressureClassification {
switch (systolicValue, diastoicValue) {
case (SystolicRanges.severeHyperTensionRange, _), (_, DiastolicRanges.severeHyperTensionRange):
return .severeHypertension
case (SystolicRanges.moderateHypertensionRange, _), (_, DiastolicRanges.moderateHypertensionRange):
return .moderateHypertension
case (SystolicRanges.mildHypertensionRange, _), (_, DiastolicRanges.mildHypertensionRange):
View BloodPressureClassifier.swift
class BloodPressureClassifier {
static func classifyBloodpessure(systolicValue: Int, diastoicValue: Int) -> BloodPressureClassification {
switch (systolicValue, diastoicValue) {
case (SystolicRanges.severeHyperTensionRange, _):
fallthrough
case (_, DiastolicRanges.severeHyperTensionRange):
return .severeHypertension
case (SystolicRanges.moderateHypertensionRange, _):
View PMOBloodPressureConstants.swift
enum SystolicRanges {
// In the Health App the range is set up between 40 and 300
static let baseRange = 40...119
static let normalRange = 120...129
static let highNormalRange = 130...139
static let mildHypertensionRange = 140...159
static let moderateHypertensionRange = 160...179
static let severeHyperTensionRange = 180...300
case outOfRange
}
@petermolnar-dev
petermolnar-dev / PMOSystolicRangesWithStaticEnums.swift
Created Mar 21, 2020
PMOSystolic Ranges with Static enum values
View PMOSystolicRangesWithStaticEnums.swift
enum SystolicRanges {
// In the Health App the range is set up between 40 and 300
static let baseRange = 40...119
static let normalRange = 120...129
static let highNormalRange = 130...139
static let mildHypertensionRange = 140...159
static let moderateHypertensionRange = 160...179
static let severeHyperTensionRange = 180...300
case outOfRange
}
View PMOSystolicRangesEnumsWithRange.swift
enum SystolicRanges {
// In the Health App the range is set up between 40 and 300
case baseRange = 40...119
case normalRange = 120...129
case highNormalRange = 130...139
case mildHypertensionRange = 140...159
case moderateHypertensionRange = 160...179
case severeHyperTensionRange = 180...300
case outOfRange
}
View PMOSystolicRangeBaseEnums.swift
enum SystolicRanges {
case baseRange
case normalRange
case highNormalRange
case mildHypertensionRange
case moderateHypertensionRange
case severeHyperTensionRange
case outOfRange
}
@petermolnar-dev
petermolnar-dev / 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-dev
petermolnar-dev / 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-dev
petermolnar-dev / 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-dev
petermolnar-dev / 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
You can’t perform that action at this time.