Fix a retain cycle in the Objective-C platform_channel example (#22321)
This commit is contained in:
parent
7d47f04ddc
commit
1dc3e98af0
@ -19,10 +19,11 @@
|
||||
FlutterMethodChannel* batteryChannel = [FlutterMethodChannel
|
||||
methodChannelWithName:@"samples.flutter.io/battery"
|
||||
binaryMessenger:controller];
|
||||
__weak typeof(self) weakSelf = self;
|
||||
[batteryChannel setMethodCallHandler:^(FlutterMethodCall* call,
|
||||
FlutterResult result) {
|
||||
if ([@"getBatteryLevel" isEqualToString:call.method]) {
|
||||
int batteryLevel = [self getBatteryLevel];
|
||||
int batteryLevel = [weakSelf getBatteryLevel];
|
||||
if (batteryLevel == -1) {
|
||||
result([FlutterError errorWithCode:@"UNAVAILABLE"
|
||||
message:@"Battery info unavailable"
|
||||
|
Loading…
x
Reference in New Issue
Block a user