Coverts to Objective-C ARC.

This commit is contained in:
zonble 2021-02-28 21:38:59 +08:00
parent 0f05e245a5
commit 6341270696
5 changed files with 98 additions and 31 deletions

View File

@ -975,6 +975,7 @@
ALWAYS_SEARCH_USER_PATHS = NO; ALWAYS_SEARCH_USER_PATHS = NO;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = YES; CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "-"; CODE_SIGN_IDENTITY = "-";
@ -1012,6 +1013,7 @@
ALWAYS_SEARCH_USER_PATHS = NO; ALWAYS_SEARCH_USER_PATHS = NO;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = YES; CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "-"; CODE_SIGN_IDENTITY = "-";

View File

@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1240"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "6ACA41CA15FC1D7500935EF6"
BuildableName = "McBopomofoInstaller.app"
BlueprintName = "McBopomofoInstaller"
ReferencedContainer = "container:McBopomofo.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "6ACA41CA15FC1D7500935EF6"
BuildableName = "McBopomofoInstaller.app"
BlueprintName = "McBopomofoInstaller"
ReferencedContainer = "container:McBopomofo.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "6ACA41CA15FC1D7500935EF6"
BuildableName = "McBopomofoInstaller.app"
BlueprintName = "McBopomofoInstaller"
ReferencedContainer = "container:McBopomofo.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@ -34,20 +34,20 @@
ArchiveUtil *_archiveUtil; ArchiveUtil *_archiveUtil;
NSString *_installingVersion; NSString *_installingVersion;
BOOL _upgrading; BOOL _upgrading;
NSButton *_installButton; NSButton *__weak _installButton;
NSButton *_cancelButton; NSButton *__weak _cancelButton;
NSTextView *_textView; NSTextView *__unsafe_unretained _textView;
NSWindow *_progressSheet; NSWindow *__weak _progressSheet;
NSProgressIndicator *_progressIndicator; NSProgressIndicator *__weak _progressIndicator;
NSDate *_translocationRemovalStartTime; NSDate *_translocationRemovalStartTime;
NSInteger _currentVersionNumber; NSInteger _currentVersionNumber;
} }
- (IBAction)agreeAndInstallAction:(id)sender; - (IBAction)agreeAndInstallAction:(id)sender;
- (IBAction)cancelAction:(id)sender; - (IBAction)cancelAction:(id)sender;
@property (assign) IBOutlet NSButton *installButton; @property (weak) IBOutlet NSButton *installButton;
@property (assign) IBOutlet NSButton *cancelButton; @property (weak) IBOutlet NSButton *cancelButton;
@property (assign) IBOutlet NSTextView *textView; @property (unsafe_unretained) IBOutlet NSTextView *textView;
@property (assign) IBOutlet NSWindow *progressSheet; @property (weak) IBOutlet NSWindow *progressSheet;
@property (assign) IBOutlet NSProgressIndicator *progressIndicator; @property (weak) IBOutlet NSProgressIndicator *progressIndicator;
@end @end

View File

@ -46,7 +46,6 @@ void RunAlertPanel(NSString *title, NSString *message, NSString *buttonTitle) {
[alert setInformativeText:message]; [alert setInformativeText:message];
[alert addButtonWithTitle:buttonTitle]; [alert addButtonWithTitle:buttonTitle];
[alert runModal]; [alert runModal];
[alert autorelease];
} }
@implementation AppDelegate @implementation AppDelegate
@ -56,17 +55,10 @@ void RunAlertPanel(NSString *title, NSString *message, NSString *buttonTitle) {
@synthesize progressSheet = _progressSheet; @synthesize progressSheet = _progressSheet;
@synthesize progressIndicator = _progressIndicator; @synthesize progressIndicator = _progressIndicator;
- (void)dealloc
{
[_archiveUtil release];
[_installingVersion release];
[_translocationRemovalStartTime release];
[super dealloc];
}
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{ {
_installingVersion = [[[[NSBundle mainBundle] infoDictionary] objectForKey:(id)kCFBundleVersionKey] retain]; _installingVersion = [[[NSBundle mainBundle] infoDictionary] objectForKey:(id)kCFBundleVersionKey];
NSString *versionString = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]; NSString *versionString = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
_archiveUtil = [[ArchiveUtil alloc] initWithAppName:kTargetBin targetAppBundleName:kTargetBundle]; _archiveUtil = [[ArchiveUtil alloc] initWithAppName:kTargetBin targetAppBundleName:kTargetBundle];
@ -76,9 +68,9 @@ void RunAlertPanel(NSString *title, NSString *message, NSString *buttonTitle) {
[self.installButton setNextKeyView:self.cancelButton]; [self.installButton setNextKeyView:self.cancelButton];
[[self window] setDefaultButtonCell:[self.installButton cell]]; [[self window] setDefaultButtonCell:[self.installButton cell]];
NSAttributedString *attrStr = [[[NSAttributedString alloc] initWithRTF:[NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"License" ofType:@"rtf"]] documentAttributes:NULL] autorelease]; NSAttributedString *attrStr = [[NSAttributedString alloc] initWithRTF:[NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"License" ofType:@"rtf"]] documentAttributes:NULL];
NSMutableAttributedString *mutableAttrStr = [[attrStr mutableCopy] autorelease]; NSMutableAttributedString *mutableAttrStr = [attrStr mutableCopy];
[mutableAttrStr addAttribute:NSForegroundColorAttributeName value:[NSColor controlTextColor] range:NSMakeRange(0, [mutableAttrStr length])]; [mutableAttrStr addAttribute:NSForegroundColorAttributeName value:[NSColor controlTextColor] range:NSMakeRange(0, [mutableAttrStr length])];
[[self.textView textStorage] setAttributedString:mutableAttrStr]; [[self.textView textStorage] setAttributedString:mutableAttrStr];
[self.textView setSelectedRange:NSMakeRange(0, 0)]; [self.textView setSelectedRange:NSMakeRange(0, 0)];
@ -145,8 +137,7 @@ void RunAlertPanel(NSString *title, NSString *message, NSString *buttonTitle) {
}); });
}]; }];
[_translocationRemovalStartTime release]; _translocationRemovalStartTime = [NSDate date];
_translocationRemovalStartTime = [[NSDate date] retain];
[NSTimer scheduledTimerWithTimeInterval:kTranslocationRemovalTickInterval target:self selector:@selector(timerTick:) userInfo:nil repeats:YES]; [NSTimer scheduledTimerWithTimeInterval:kTranslocationRemovalTickInterval target:self selector:@selector(timerTick:) userInfo:nil repeats:YES];
return; return;
} }

View File

@ -28,16 +28,15 @@
targetAppBundleName:(NSString *)targetAppBundleName { targetAppBundleName:(NSString *)targetAppBundleName {
self = [super init]; self = [super init];
if (self) { if (self) {
_appName = [name retain]; _appName = name;
_targetAppBundleName = [targetAppBundleName retain]; _targetAppBundleName = targetAppBundleName;
} }
return self; return self;
} }
- (void)delloc { - (void)delloc {
[_appName release]; _appName = nil;
[_targetAppBundleName release]; _targetAppBundleName = nil;
[super dealloc];
} }
- (BOOL)validateIfNotarizedArchiveExists { - (BOOL)validateIfNotarizedArchiveExists {
@ -67,7 +66,6 @@
devModeAppBundleExists]]; devModeAppBundleExists]];
[alert addButtonWithTitle:@"Terminate"]; [alert addButtonWithTitle:@"Terminate"];
[alert runModal]; [alert runModal];
[alert autorelease];
[[NSApplication sharedApplication] terminate:nil]; [[NSApplication sharedApplication] terminate:nil];
} else { } else {
@ -84,8 +82,6 @@
devModeAppBundlePath]]; devModeAppBundlePath]];
[alert addButtonWithTitle:@"Terminate"]; [alert addButtonWithTitle:@"Terminate"];
[alert runModal]; [alert runModal];
[alert autorelease];
[[NSApplication sharedApplication] terminate:nil]; [[NSApplication sharedApplication] terminate:nil];
} }