我有一个GPS应用程序已经使用了相当数量的电池。由于应用程序的性质,我不希望用户在他们的电池不知情的情况下死亡时丢失所有数据。所以,我想我会监视电池,然后保存并停止GPS数据,如果电池电量很低。我会用:iOS:监控电池电量使用更多电池?应该自动保存?
[[UIDevice currentDevice] setBatteryMonitoringEnabled:YES];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(batteryStateDidChange:)
name:UIDeviceBatteryStateDidChangeNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(batteryLevelDidChange:)
name:UIDeviceBatteryLevelDidChangeNotification
object:nil];
所以,有几个问题:
- 会监控电池造成更大的电池消耗?
- 在电池没电之前自动为用户保存(核心数据)是一个好主意吗?
谢谢,我需要这个确认。 –