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
{
if (sharedInstance)
[self release];
else
sharedInstance = [super init];
if (!sharedInstance) sharedInstance = [super init];
return sharedInstance;
}

View File

@ -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

View File

@ -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 = (