UIApplication+YYAdd.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. //
  2. // UIApplication+YYAdd.h
  3. // YYKit <https://github.com/ibireme/YYKit>
  4. //
  5. // Created by ibireme on 13/4/4.
  6. // Copyright (c) 2015 ibireme.
  7. //
  8. // This source code is licensed under the MIT-style license found in the
  9. // LICENSE file in the root directory of this source tree.
  10. //
  11. #import <UIKit/UIKit.h>
  12. NS_ASSUME_NONNULL_BEGIN
  13. /**
  14. Provides extensions for `UIApplication`.
  15. */
  16. @interface UIApplication (YYAdd)
  17. /// "Documents" folder in this app's sandbox.
  18. @property (nonatomic, readonly) NSURL *documentsURL;
  19. @property (nonatomic, readonly) NSString *documentsPath;
  20. /// "Caches" folder in this app's sandbox.
  21. @property (nonatomic, readonly) NSURL *cachesURL;
  22. @property (nonatomic, readonly) NSString *cachesPath;
  23. /// "Library" folder in this app's sandbox.
  24. @property (nonatomic, readonly) NSURL *libraryURL;
  25. @property (nonatomic, readonly) NSString *libraryPath;
  26. /// Application's Bundle Name (show in SpringBoard).
  27. @property (nullable, nonatomic, readonly) NSString *appBundleName;
  28. /// Application's Bundle ID. e.g. "com.ibireme.MyApp"
  29. @property (nullable, nonatomic, readonly) NSString *appBundleID;
  30. /// Application's Version. e.g. "1.2.0"
  31. @property (nullable, nonatomic, readonly) NSString *appVersion;
  32. /// Application's Build number. e.g. "123"
  33. @property (nullable, nonatomic, readonly) NSString *appBuildVersion;
  34. /// Whether this app is pirated (not install from appstore).
  35. @property (nonatomic, readonly) BOOL isPirated;
  36. /// Whether this app is being debugged (debugger attached).
  37. @property (nonatomic, readonly) BOOL isBeingDebugged;
  38. /// Current thread real memory used in byte. (-1 when error occurs)
  39. @property (nonatomic, readonly) int64_t memoryUsage;
  40. /// Current thread CPU usage, 1.0 means 100%. (-1 when error occurs)
  41. @property (nonatomic, readonly) float cpuUsage;
  42. /**
  43. Increments the number of active network requests.
  44. If this number was zero before incrementing, this will start animating the
  45. status bar network activity indicator.
  46. This method is thread safe.
  47. This method has no effect in App Extension.
  48. */
  49. - (void)incrementNetworkActivityCount;
  50. /**
  51. Decrements the number of active network requests.
  52. If this number becomes zero after decrementing, this will stop animating the
  53. status bar network activity indicator.
  54. This method is thread safe.
  55. This method has no effect in App Extension.
  56. */
  57. - (void)decrementNetworkActivityCount;
  58. /// Returns YES in App Extension.
  59. + (BOOL)isAppExtension;
  60. /// Same as sharedApplication, but returns nil in App Extension.
  61. + (nullable UIApplication *)sharedExtensionApplication;
  62. @end
  63. NS_ASSUME_NONNULL_END