文档

此处整理出有用的苹果相关开发文档,供需要时查阅。

iOS 旧文档

iOS 新文档

统一后的 = 新的

UIDeviceBatteryState - UIKit | Apple Developer Documentation

typedef enum UIDeviceBatteryState : NSInteger {
    ...
} UIDeviceBatteryState;
  • Constants
    • UIDeviceBatteryStateUnknown
      • The battery state for the device cannot be determined.
    • UIDeviceBatteryStateUnplugged
      • The device is not plugged into power; the battery is discharging.
    • UIDeviceBatteryStateCharging
      • The device is plugged into power and the battery is less than 100% charged.
    • UIDeviceBatteryStateFull
      • The device is plugged into power and the battery is 100% charged.

-》想要知道对应的枚举值定义的int值

-》

UIDeviceBatteryStateUnknown - UIDeviceBatteryState | Apple Developer Documentation

The battery state for the device cannot be determined.

UIDeviceBatteryStateUnknown

-》没看到定义的值

-》无意间发现,换Swift语言后:

UIDevice.BatteryState - UIDevice | Apple Developer Documentation

-》点击具体的某个定义,都可以看到具体常量枚举值定义:

-》总结来说:

此处是ObjC中看不到UIDeviceBatteryState的细节的枚举值的定义

而换成SwiftUIDevice.BatteryState,就可以看到具体的枚举的定义的常量的值了

results matching ""

    No results matching ""