Convert to ARC.

This commit is contained in:
Christian Speckner 2019-04-14 18:52:58 +02:00
parent d63f68508f
commit 0f3648ee09
3 changed files with 20 additions and 24 deletions

View File

@ -38,10 +38,7 @@ static AboutBox *sharedInstance = nil;
- (id)init - (id)init
{ {
if (sharedInstance) if (!sharedInstance) sharedInstance = [super init];
[self release];
else
sharedInstance = [super init];
return sharedInstance; return sharedInstance;
} }

View File

@ -49,7 +49,7 @@ static Preferences *sharedInstance = nil;
- (id)init - (id)init
{ {
if (self = [super init]) { if (self = [super init]) {
defaults = [[NSUserDefaults standardUserDefaults] retain]; defaults = [NSUserDefaults standardUserDefaults];
sharedInstance = self; sharedInstance = self;
} }
return(self); return(self);
@ -57,42 +57,39 @@ static Preferences *sharedInstance = nil;
- (void)dealloc - (void)dealloc
{ {
[defaults release];
if (self == sharedInstance) { if (self == sharedInstance) {
sharedInstance = nil; sharedInstance = nil;
} }
[super dealloc];
} }
- (void)setString:(const char *)key : (const char *)value - (void)setString:(const char *)key : (const char *)value
{ {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; @autoreleasepool {
NSString* theKey = [NSString stringWithCString:key encoding:NSUTF8StringEncoding]; NSString* theKey = [NSString stringWithCString:key encoding:NSUTF8StringEncoding];
NSString* theValue = [NSString stringWithCString:value encoding:NSUTF8StringEncoding]; NSString* theValue = [NSString stringWithCString:value encoding:NSUTF8StringEncoding];
[defaults setObject:theValue forKey:theKey]; [defaults setObject:theValue forKey:theKey];
[pool release]; }
} }
- (void)getString:(const char *)key : (char *)value : (int)size - (void)getString:(const char *)key : (char *)value : (int)size
{ {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; @autoreleasepool {
NSString* theKey = [NSString stringWithCString:key encoding:NSUTF8StringEncoding]; NSString* theKey = [NSString stringWithCString:key encoding:NSUTF8StringEncoding];
NSString* theValue = [defaults objectForKey:theKey]; NSString* theValue = [defaults objectForKey:theKey];
if (theValue != nil) if (theValue != nil)
strncpy(value, [theValue cStringUsingEncoding: NSUTF8StringEncoding], size); strncpy(value, [theValue cStringUsingEncoding: NSUTF8StringEncoding], size);
else else
value[0] = 0; value[0] = 0;
}
[pool release];
} }
- (void)save - (void)save
{ {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; @autoreleasepool {
[defaults synchronize]; [defaults synchronize];
[pool release]; }
} }
@end @end

View File

@ -3014,6 +3014,7 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO; ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = YES; CLANG_ENABLE_OBJC_WEAK = YES;
COMBINE_HIDPI_IMAGES = YES; COMBINE_HIDPI_IMAGES = YES;
FRAMEWORK_SEARCH_PATHS = ( FRAMEWORK_SEARCH_PATHS = (
@ -3067,6 +3068,7 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO; ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = YES; CLANG_ENABLE_OBJC_WEAK = YES;
COMBINE_HIDPI_IMAGES = YES; COMBINE_HIDPI_IMAGES = YES;
FRAMEWORK_SEARCH_PATHS = ( FRAMEWORK_SEARCH_PATHS = (