mirror of
https://github.com/Instagram/IGListKit
synced 2026-05-24 01:38:26 +00:00
Don't call [UIDevice currentDevice] in +load
Summary: sysctl should be faster. Reviewed By: timonus Differential Revision: D13981833 fbshipit-source-id: ae7a67d4eb69595441a4a66e0ef0a271762f77ce
This commit is contained in:
parent
46a124ddfe
commit
035808e750
4 changed files with 28 additions and 2 deletions
|
|
@ -10,6 +10,7 @@
|
|||
#import <IGListKit/IGListAssert.h>
|
||||
#import <IGListKit/IGListAdapterUpdater.h>
|
||||
#import <IGListKit/IGListSupplementaryViewSource.h>
|
||||
#import <IGListKit/IGSystemVersion.h>
|
||||
|
||||
#import "IGListSectionControllerInternal.h"
|
||||
#import "IGListDebugger.h"
|
||||
|
|
@ -26,7 +27,7 @@
|
|||
|
||||
- (void)dealloc {
|
||||
// on iOS 9 setting the dataSource has side effects that can invalidate the layout and seg fault
|
||||
if ([[[UIDevice currentDevice] systemVersion] floatValue] < 9.0) {
|
||||
if (!IGSystemVersionIsIOS9OrNewer()) {
|
||||
// properties are assign for <iOS 9
|
||||
_collectionView.dataSource = nil;
|
||||
_collectionView.delegate = nil;
|
||||
|
|
|
|||
8
Source/Internal/IGSystemVersion.h
Normal file
8
Source/Internal/IGSystemVersion.h
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
bool IGSystemVersionIsIOS9OrNewer(void);
|
||||
16
Source/Internal/IGSystemVersion.m
Normal file
16
Source/Internal/IGSystemVersion.m
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#import "IGSystemVersion.h"
|
||||
|
||||
bool IGSystemVersionIsIOS9OrNewer(void) {
|
||||
if (@available(iOS 9.0, *)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -11,6 +11,7 @@
|
|||
#import <IGListKit/IGListAdapterInternal.h>
|
||||
#import <IGListKit/IGListAssert.h>
|
||||
#import <IGListKit/IGListSectionController.h>
|
||||
#import <IGListKit/IGSystemVersion.h>
|
||||
|
||||
#import <objc/runtime.h>
|
||||
|
||||
|
|
@ -23,7 +24,7 @@ static void * kIGListAdapterKey = &kIGListAdapterKey;
|
|||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
// interactive reordering does not exist prior to iOS 9
|
||||
if ([[[UIDevice currentDevice] systemVersion] floatValue] < 9.0) {
|
||||
if (!IGSystemVersionIsIOS9OrNewer()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue