相关疑难解决方法(0)

NSVotificationCenter在Swift中添加了addObserver

如何在Swift中将观察者添加到默认通知中心?我正在尝试移植这行代码,以便在电池电量发生变化时发送通知.

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(batteryLevelChanged:) name:UIDeviceBatteryLevelDidChangeNotification object:nil];
Run Code Online (Sandbox Code Playgroud)

nsnotificationcenter ios swift

382
推荐指数
9
解决办法
27万
查看次数

标签 统计

ios ×1

nsnotificationcenter ×1

swift ×1