Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
//
// UIDevice+DTFeatureCheck.h
// DTUIKit
//
// Created by Daniel Tull on 02.08.2010.
// Copyright 2010 Daniel Tull. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface UIDevice (DTFeatureCheck)
- (BOOL)dt_multitaskingSupported;
- (BOOL)dt_blocksSupported;
@end
//
// UIDevice+DTFeatureCheck.m
// DTUIKit
//
// Created by Daniel Tull on 02.08.2010.
// Copyright 2010 Daniel Tull. All rights reserved.
//
#import "UIDevice+DTFeatureCheck.h"
#import "UIDevice+DTSystemVersion.h"
@implementation UIDevice (DTFeatureCheck)
- (BOOL)dt_multitaskingSupported {
if (![self respondsToSelector:@selector(isMultitaskingSupported)]) return NO;
return self.multitaskingSupported;
}
- (BOOL)dt_blocksSupported {
return ([self dt_majorSystemVersion] >= 4);
}
@end
//
// UIDevice+DTSystemVersion.h
// DTUIKit
//
// Created by Daniel Tull on 26.06.2009.
// Copyright 2009 Daniel Tull. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface UIDevice (DTSystemVersion)
- (NSInteger)dt_majorSystemVersion;
- (NSInteger)dt_minorSystemVersion;
- (NSInteger)dt_maintenanceSystemVersion;
@end
//
// UIDevice+DTSystemVersion.m
// DTUIKit
//
// Created by Daniel Tull on 26.06.2009.
// Copyright 2009 Daniel Tull. All rights reserved.
//
#import "UIDevice+DTSystemVersion.h"
@interface UIDevice ()
- (NSInteger)dtInternal_systemVersionComponentAtIndex:(NSInteger)index;
@end
@implementation UIDevice (DTSystemVersion)
- (NSInteger)dtInternal_systemVersionComponentAtIndex:(NSInteger)index {
NSArray *components = [self.systemVersion componentsSeparatedByString:@"."];
if ([components count] <= index) return -1;
return [[components objectAtIndex:index] integerValue];
}
- (NSInteger)dt_majorSystemVersion {
return [self dtInternal_systemVersionComponentAtIndex:0];
}
- (NSInteger)dt_minorSystemVersion {
return [self dtInternal_systemVersionComponentAtIndex:1];
}
- (NSInteger)dt_maintenanceSystemVersion {
return [self dtInternal_systemVersionComponentAtIndex:2];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment