Skip to content

Instantly share code, notes, and snippets.

@danielctull
Created September 5, 2010 08:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielctull/565853 to your computer and use it in GitHub Desktop.
Save danielctull/565853 to your computer and use it in GitHub Desktop.
//
// 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