From 0f3648ee09868b00b00d93eb9642767b7e8963d1 Mon Sep 17 00:00:00 2001 From: Christian Speckner Date: Sun, 14 Apr 2019 18:52:58 +0200 Subject: [PATCH] Convert to ARC. --- src/macos/AboutBox.m | 5 +-- src/macos/Preferences.m | 37 ++++++++++------------ src/macos/stella.xcodeproj/project.pbxproj | 2 ++ 3 files changed, 20 insertions(+), 24 deletions(-) diff --git a/src/macos/AboutBox.m b/src/macos/AboutBox.m index b83154b2b..d73a78297 100644 --- a/src/macos/AboutBox.m +++ b/src/macos/AboutBox.m @@ -38,10 +38,7 @@ static AboutBox *sharedInstance = nil; - (id)init { - if (sharedInstance) - [self release]; - else - sharedInstance = [super init]; + if (!sharedInstance) sharedInstance = [super init]; return sharedInstance; } diff --git a/src/macos/Preferences.m b/src/macos/Preferences.m index db911397a..69e2dee63 100644 --- a/src/macos/Preferences.m +++ b/src/macos/Preferences.m @@ -49,7 +49,7 @@ static Preferences *sharedInstance = nil; - (id)init { if (self = [super init]) { - defaults = [[NSUserDefaults standardUserDefaults] retain]; + defaults = [NSUserDefaults standardUserDefaults]; sharedInstance = self; } return(self); @@ -57,42 +57,39 @@ static Preferences *sharedInstance = nil; - (void)dealloc { - [defaults release]; if (self == sharedInstance) { sharedInstance = nil; } - [super dealloc]; } - (void)setString:(const char *)key : (const char *)value { - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - NSString* theKey = [NSString stringWithCString:key encoding:NSUTF8StringEncoding]; - NSString* theValue = [NSString stringWithCString:value encoding:NSUTF8StringEncoding]; + @autoreleasepool { + NSString* theKey = [NSString stringWithCString:key encoding:NSUTF8StringEncoding]; + NSString* theValue = [NSString stringWithCString:value encoding:NSUTF8StringEncoding]; - [defaults setObject:theValue forKey:theKey]; - [pool release]; + [defaults setObject:theValue forKey:theKey]; + } } - (void)getString:(const char *)key : (char *)value : (int)size { - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - NSString* theKey = [NSString stringWithCString:key encoding:NSUTF8StringEncoding]; - NSString* theValue = [defaults objectForKey:theKey]; - if (theValue != nil) - strncpy(value, [theValue cStringUsingEncoding: NSUTF8StringEncoding], size); - else - value[0] = 0; - - [pool release]; + @autoreleasepool { + NSString* theKey = [NSString stringWithCString:key encoding:NSUTF8StringEncoding]; + NSString* theValue = [defaults objectForKey:theKey]; + if (theValue != nil) + strncpy(value, [theValue cStringUsingEncoding: NSUTF8StringEncoding], size); + else + value[0] = 0; + } } - (void)save { - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - [defaults synchronize]; - [pool release]; + @autoreleasepool { + [defaults synchronize]; + } } @end diff --git a/src/macos/stella.xcodeproj/project.pbxproj b/src/macos/stella.xcodeproj/project.pbxproj index 6d07b68d0..7a46ed1c7 100644 --- a/src/macos/stella.xcodeproj/project.pbxproj +++ b/src/macos/stella.xcodeproj/project.pbxproj @@ -3014,6 +3014,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ENABLE_OBJC_ARC = YES; CLANG_ENABLE_OBJC_WEAK = YES; COMBINE_HIDPI_IMAGES = YES; FRAMEWORK_SEARCH_PATHS = ( @@ -3067,6 +3068,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ENABLE_OBJC_ARC = YES; CLANG_ENABLE_OBJC_WEAK = YES; COMBINE_HIDPI_IMAGES = YES; FRAMEWORK_SEARCH_PATHS = (