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;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "-";
@ -1012,6 +1013,7 @@
ALWAYS_SEARCH_USER_PATHS = NO;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
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;
NSString *_installingVersion;
BOOL _upgrading;
NSButton *_installButton;
NSButton *_cancelButton;
NSTextView *_textView;
NSWindow *_progressSheet;
NSProgressIndicator *_progressIndicator;
NSButton *__weak _installButton;
NSButton *__weak _cancelButton;
NSTextView *__unsafe_unretained _textView;
NSWindow *__weak _progressSheet;
NSProgressIndicator *__weak _progressIndicator;
NSDate *_translocationRemovalStartTime;
NSInteger _currentVersionNumber;
}
- (IBAction)agreeAndInstallAction:(id)sender;
- (IBAction)cancelAction:(id)sender;
@property (assign) IBOutlet NSButton *installButton;
@property (assign) IBOutlet NSButton *cancelButton;
@property (assign) IBOutlet NSTextView *textView;
@property (assign) IBOutlet NSWindow *progressSheet;
@property (assign) IBOutlet NSProgressIndicator *progressIndicator;
@property (weak) IBOutlet NSButton *installButton;
@property (weak) IBOutlet NSButton *cancelButton;
@property (unsafe_unretained) IBOutlet NSTextView *textView;
@property (weak) IBOutlet NSWindow *progressSheet;
@property (weak) IBOutlet NSProgressIndicator *progressIndicator;
@end

View File

@ -46,7 +46,6 @@ void RunAlertPanel(NSString *title, NSString *message, NSString *buttonTitle) {
[alert setInformativeText:message];
[alert addButtonWithTitle:buttonTitle];
[alert runModal];
[alert autorelease];
}
@implementation AppDelegate
@ -56,17 +55,10 @@ void RunAlertPanel(NSString *title, NSString *message, NSString *buttonTitle) {
@synthesize progressSheet = _progressSheet;
@synthesize progressIndicator = _progressIndicator;
- (void)dealloc
{
[_archiveUtil release];
[_installingVersion release];
[_translocationRemovalStartTime release];
[super dealloc];
}
- (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"];
_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 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])];
[[self.textView textStorage] setAttributedString:mutableAttrStr];
[self.textView setSelectedRange:NSMakeRange(0, 0)];
@ -145,8 +137,7 @@ void RunAlertPanel(NSString *title, NSString *message, NSString *buttonTitle) {
});
}];
[_translocationRemovalStartTime release];
_translocationRemovalStartTime = [[NSDate date] retain];
_translocationRemovalStartTime = [NSDate date];
[NSTimer scheduledTimerWithTimeInterval:kTranslocationRemovalTickInterval target:self selector:@selector(timerTick:) userInfo:nil repeats:YES];
return;
}

View File

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