iOS,macOS: Fix string constant declarations (flutter/engine#56661)
A couple string constants had been incorrectly declared `const NSString*` rather than `NSString* const`. The former is a pointer to an immutable string, but (a) the pointer can be reassigned and (b) the default NSString implementation is immutable. The latter is an immutable pointer to a string, which is what we want, since we don't want developers reassinging our constants to other values. Also updates an identifier name to pass lint rules. No changes to tests since this is "tested" by the compiler. [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
extern const NSString* kDefaultAssetPath;
|
||||
extern NSString* const kDefaultAssetPath;
|
||||
|
||||
// Finds a bundle with the named `flutterFrameworkBundleID` within `searchURL`.
|
||||
//
|
||||
|
||||
@@ -2,13 +2,16 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#import "flutter/shell/platform/darwin/common/framework/Source/FlutterNSBundleUtils.h"
|
||||
|
||||
#include <Foundation/Foundation.h>
|
||||
|
||||
#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterMacros.h"
|
||||
|
||||
FLUTTER_ASSERT_ARC
|
||||
|
||||
const NSString* kDefaultAssetPath = @"Frameworks/App.framework/flutter_assets";
|
||||
NSString* const kDefaultAssetPath = @"Frameworks/App.framework/flutter_assets";
|
||||
|
||||
static NSString* GetFlutterAssetsPathFromBundle(NSBundle* bundle, NSString* relativeAssetsPath);
|
||||
|
||||
NSBundle* FLTFrameworkBundleInternal(NSString* flutterFrameworkBundleID, NSURL* searchURL) {
|
||||
|
||||
@@ -23,7 +23,7 @@ constexpr char kTextPlainFormat[] = "text/plain";
|
||||
const UInt32 kKeyPressClickSoundId = 1306;
|
||||
|
||||
#if not APPLICATION_EXTENSION_API_ONLY
|
||||
const NSString* searchURLPrefix = @"x-web-search://?";
|
||||
NSString* const kSearchURLPrefix = @"x-web-search://?";
|
||||
#endif
|
||||
|
||||
} // namespace
|
||||
@@ -226,7 +226,7 @@ static void SetStatusBarStyleForSharedApplication(UIStatusBarStyle style) {
|
||||
NSString* escapedText = [searchTerm
|
||||
stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet
|
||||
URLHostAllowedCharacterSet]];
|
||||
NSString* searchURL = [NSString stringWithFormat:@"%@%@", searchURLPrefix, escapedText];
|
||||
NSString* searchURL = [NSString stringWithFormat:@"%@%@", kSearchURLPrefix, escapedText];
|
||||
|
||||
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:searchURL]
|
||||
options:@{}
|
||||
|
||||
Reference in New Issue
Block a user