From 1dc3e98af0c64326b0c90a3113c9e022e464c64d Mon Sep 17 00:00:00 2001 From: "James D. Lin" Date: Thu, 27 Sep 2018 09:45:50 -0700 Subject: [PATCH] Fix a retain cycle in the Objective-C platform_channel example (#22321) --- examples/platform_channel/ios/Runner/AppDelegate.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/platform_channel/ios/Runner/AppDelegate.m b/examples/platform_channel/ios/Runner/AppDelegate.m index 2c0add8359..e047ef9c1f 100644 --- a/examples/platform_channel/ios/Runner/AppDelegate.m +++ b/examples/platform_channel/ios/Runner/AppDelegate.m @@ -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"