Skip to content

Commit

Permalink
iOS: Migrate FlutterPlatformPlugin to ARC
Browse files Browse the repository at this point in the history
Migrates from manual reference counting to automatic reference counting.

Issue: flutter/flutter#137801
  • Loading branch information
cbracken committed Oct 1, 2024
1 parent ab48d6d commit e1a3d8a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
4 changes: 2 additions & 2 deletions shell/platform/darwin/ios/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ source_set("flutter_framework_source_arc") {
"framework/Source/FlutterMetalLayer.mm",
"framework/Source/FlutterOverlayView.h",
"framework/Source/FlutterOverlayView.mm",
"framework/Source/FlutterPlatformPlugin.h",
"framework/Source/FlutterPlatformPlugin.mm",
"framework/Source/FlutterPlatformViews_Internal.h",
"framework/Source/FlutterPlatformViews_Internal.mm",
"framework/Source/FlutterPluginAppLifeCycleDelegate.mm",
Expand Down Expand Up @@ -184,8 +186,6 @@ source_set("flutter_framework_source") {
# To add new files in ARC, add them to the `flutter_framework_source_arc` target.
"framework/Source/FlutterEngine.mm",
"framework/Source/FlutterEngine_Internal.h",
"framework/Source/FlutterPlatformPlugin.h",
"framework/Source/FlutterPlatformPlugin.mm",
"framework/Source/FlutterViewController.mm",
"framework/Source/FlutterViewController_Internal.h",
"framework/Source/accessibility_bridge.h",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterViewController_Internal.h"
#import "flutter/shell/platform/darwin/ios/framework/Source/UIViewController+FlutterScreenAndSceneIfLoaded.h"

FLUTTER_ASSERT_ARC

namespace {

constexpr char kTextPlainFormat[] = "text/plain";
Expand Down Expand Up @@ -184,8 +186,8 @@ - (void)showShareViewController:(NSString*)content {

NSArray* itemsToShare = @[ content ?: [NSNull null] ];
UIActivityViewController* activityViewController =
[[[UIActivityViewController alloc] initWithActivityItems:itemsToShare
applicationActivities:nil] autorelease];
[[UIActivityViewController alloc] initWithActivityItems:itemsToShare
applicationActivities:nil];

if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
// On iPad, the share screen is presented in a popover view, and requires a
Expand Down Expand Up @@ -246,16 +248,13 @@ - (void)vibrateHapticFeedback:(NSString*)feedbackType {
}

if ([@"HapticFeedbackType.lightImpact" isEqualToString:feedbackType]) {
[[[[UIImpactFeedbackGenerator alloc] initWithStyle:UIImpactFeedbackStyleLight] autorelease]
impactOccurred];
[[[UIImpactFeedbackGenerator alloc] initWithStyle:UIImpactFeedbackStyleLight] impactOccurred];
} else if ([@"HapticFeedbackType.mediumImpact" isEqualToString:feedbackType]) {
[[[[UIImpactFeedbackGenerator alloc] initWithStyle:UIImpactFeedbackStyleMedium] autorelease]
impactOccurred];
[[[UIImpactFeedbackGenerator alloc] initWithStyle:UIImpactFeedbackStyleMedium] impactOccurred];
} else if ([@"HapticFeedbackType.heavyImpact" isEqualToString:feedbackType]) {
[[[[UIImpactFeedbackGenerator alloc] initWithStyle:UIImpactFeedbackStyleHeavy] autorelease]
impactOccurred];
[[[UIImpactFeedbackGenerator alloc] initWithStyle:UIImpactFeedbackStyleHeavy] impactOccurred];
} else if ([@"HapticFeedbackType.selectionClick" isEqualToString:feedbackType]) {
[[[[UISelectionFeedbackGenerator alloc] init] autorelease] selectionChanged];
[[[UISelectionFeedbackGenerator alloc] init] selectionChanged];
}
}

Expand Down Expand Up @@ -429,7 +428,7 @@ - (BOOL)isLiveTextInputAvailable {
- (void)showLookUpViewController:(NSString*)term {
UIViewController* engineViewController = [_engine.get() viewController];
UIReferenceLibraryViewController* referenceLibraryViewController =
[[[UIReferenceLibraryViewController alloc] initWithTerm:term] autorelease];
[[UIReferenceLibraryViewController alloc] initWithTerm:term];
[engineViewController presentViewController:referenceLibraryViewController
animated:YES
completion:nil];
Expand All @@ -442,8 +441,4 @@ - (UITextField*)textField {
return _textField;
}

- (void)dealloc {
[_textField release];
[super dealloc];
}
@end

0 comments on commit e1a3d8a

Please sign in to comment.