123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198 |
- //
- // UIDevice+YLDevice.h
- // YoungCatogory
- //
- // Created by kuxuan on 2017/7/17.
- // Copyright © 2017年 kuxuan. All rights reserved.
- //
- #import <UIKit/UIKit.h>
- #import <AdSupport/AdSupport.h>
- @interface UIDevice (YLDevice)
- /**
- * Get the iOS version string
- */
- #define IOS_VERSION [UIDevice currentDevice].systemVersion
- /**
- * Macros to compare system versions
- *
- * @param v Version, like @"9.0"
- *
- * @return Returns a BOOL
- */
- #define SYSTEM_VERSION_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
- #define SYSTEM_VERSION_GREATER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
- #define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
- #define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
- #define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)
- /**
- * Macros that returns if the iOS version is greater or equal to choosed one
- *
- * @return Returns a BOOL
- */
- #define IS_IOS_5_OR_LATER ([[[UIDevice currentDevice] systemVersion] floatValue] >= 5.0)
- #define IS_IOS_6_OR_LATER ([[[UIDevice currentDevice] systemVersion] floatValue] >= 6.0)
- #define IS_IOS_7_OR_LATER ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0)
- #define IS_IOS_8_OR_LATER ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
- #define IS_IOS_9_OR_LATER ([[[UIDevice currentDevice] systemVersion] floatValue] >= 9.0)
- /**
- * Returns the device platform string
- * Example: "iPhone7,2"
- *
- * @return Returns the device platform string
- */
- + (NSString * _Nonnull)devicePlatform;
- /**
- * Returns the user-friendly device platform string
- * Example: "iPad Air (Cellular)"
- *
- * @return Returns the user-friendly device platform string
- */
- + (NSString * _Nonnull)devicePlatformString;
- /**
- * Returns current resolution string
- * Example: "320x480"
- *
- * @return Returns current resolution string
- */
- + (NSString * _Nonnull)currentResolution;
- /**
- * Check if the current device is an iPad
- *
- * @return Returns YES if it's an iPad, NO if not
- */
- + (BOOL)isiPad;
- /**
- * Check if the current device is an iPhone
- *
- * @return Returns YES if it's an iPhone, NO if not
- */
- + (BOOL)isiPhone;
- /**
- * Check if the current device is an iPod
- *
- * @return Returns YES if it's an iPod, NO if not
- */
- + (BOOL)isiPod;
- /**
- * Check if the current device is an Apple TV
- *
- * @return Returns YES if it's an Apple TV, NO if not
- */
- + (BOOL)isAppleTV;
- /**
- * Check if the current device is an Apple Watch
- *
- * @return Returns YES if it's an Apple Watch, NO if not
- */
- + (BOOL)isAppleWatch;
- /**
- * Check if the current device is the simulator
- *
- * @return Returns YES if it's the simulator, NO if not
- */
- + (BOOL)isSimulator;
- /**
- * Returns the iOS version without the subversion
- * Example: 7
- *
- * @return Returns the iOS version
- */
- + (NSInteger)iOSVersion;
- /**
- * Returns the current device CPU frequency
- *
- * @return Returns the current device CPU frequency
- */
- + (NSUInteger)cpuFrequency;
- /**
- * Returns the current device BUS frequency
- *
- * @return Returns the current device BUS frequency
- */
- + (NSUInteger)busFrequency;
- /**
- * Returns the current device RAM size
- *
- * @return Returns the current device RAM size
- */
- + (NSUInteger)ramSize;
- /**
- * Returns the current device CPU number
- *
- * @return Returns the current device CPU number
- */
- + (NSUInteger)cpuNumber;
- /**
- * Returns the current device total memory
- *
- * @return Returns the current device total memory
- //手机总磁盘
- */
- + (NSUInteger)totalMemory;
- /**
- * Returns the current device non-kernel memory
- *
- * @return Returns the current device non-kernel memory
- */
- + (NSUInteger)userMemory;
- /**
- * Returns the current device total disk space
- *
- * @return Returns the current device total disk space
- */
- + (NSNumber * _Nonnull)totalDiskSpace;
- /**
- * Returns the current device free disk space
- *
- * @return Returns the current device free disk space
- */
- + (NSNumber * _Nonnull)freeDiskSpace;
- /**
- * Generate an unique identifier and store it into standardUserDefaults
- *
- * @return Returns a unique identifier as a NSString
- */
- + (NSString * _Nonnull)uniqueIdentifier;
- /**
- * Generate an idfa and store it into standardUserDefaults
- *
- * @return Returns an idfa as a NSString
- */
- + (NSString * _Nonnull)idfaString;
- /**
- * Save the unique identifier or update it if there is and it is changed.
- * Is useful for push notification to know if the unique identifier has changed and needs to be send to server
- *
- * @param uniqueIdentifier The unique identifier to save or update if needed. (Must be NSData or NSString)
- * @param block The execution block that know if the unique identifier is valid and has to be updated. You have to handle the case if it is valid and the update is needed or not
- */
- + (void)updateUniqueIdentifier:(NSObject * _Nonnull)uniqueIdentifier block:(void (^ _Nullable)(BOOL isValid, BOOL hasToUpdateUniqueIdentifier, NSString * _Nullable oldUUID))block;
- //数据转换
- +(NSString *)fileSizeToString:(NSNumber *)fileSize;
- @end
|