Revision: 13815
http://sourceforge.net/p/skim-app/code/13815
Author: hofman
Date: 2023-11-30 10:11:22 +0000 (Thu, 30 Nov 2023)
Log Message:
-----------
use ARC for test app
Modified Paths:
--------------
trunk/SkimNotes/Configurations/SkimNotes-App.xcconfig
trunk/SkimNotes/SKNDocument.m
trunk/SkimNotes/SKNSkimReader.m
trunk/SkimNotes/SKNXPCSkimReader.m
trunk/SkimNotes/SkimNotes.xcodeproj/project.pbxproj
Modified: trunk/SkimNotes/Configurations/SkimNotes-App.xcconfig
===================================================================
--- trunk/SkimNotes/Configurations/SkimNotes-App.xcconfig 2023-11-29
16:35:30 UTC (rev 13814)
+++ trunk/SkimNotes/Configurations/SkimNotes-App.xcconfig 2023-11-30
10:11:22 UTC (rev 13815)
@@ -10,3 +10,5 @@
GCC_PRECOMPILE_PREFIX_HEADER = YES
GCC_PREFIX_HEADER =
$(SYSTEM_LIBRARY_DIR)/Frameworks/AppKit.framework/Headers/AppKit.h
+
+CLANG_ENABLE_OBJC_ARC = YES
Modified: trunk/SkimNotes/SKNDocument.m
===================================================================
--- trunk/SkimNotes/SKNDocument.m 2023-11-29 16:35:30 UTC (rev 13814)
+++ trunk/SkimNotes/SKNDocument.m 2023-11-30 10:11:22 UTC (rev 13815)
@@ -52,7 +52,7 @@
@synthesize notes;
+ (void)initialize {
- [NSValueTransformer setValueTransformer:[[[SKNPlusOneTransformer alloc]
init] autorelease] forName:@"SKNPlusOne"];
+ [NSValueTransformer setValueTransformer:[[SKNPlusOneTransformer alloc]
init] forName:@"SKNPlusOne"];
}
+ (BOOL)autosavesInPlace {
@@ -67,11 +67,6 @@
return self;
}
-- (void)dealloc {
- [notes release];
- [super dealloc];
-}
-
- (NSString *)windowNibName {
return @"SKNDocument";
}
@@ -171,7 +166,7 @@
[self setNotes:arr];
}
}];
- array = [NSArray array];
+ array = @[];
}
#elif defined(ToolSample)
@@ -212,7 +207,6 @@
if (success && [task terminationStatus] == 0 && data == nil)
data = [NSData data];
- [task release];
task = nil;
[fm removeItemAtPath:tmpDir error:NULL];
} else if ([ws type:docType conformsToType:SKNPDFBundleDocumentType]) {
@@ -238,7 +232,7 @@
if (array == nil)
array = [NSPropertyListSerialization propertyListWithData:data
options:NSPropertyListImmutable format:NULL error:NULL];
} else {
- array = [NSArray array];
+ array = @[];
}
}
Modified: trunk/SkimNotes/SKNSkimReader.m
===================================================================
--- trunk/SkimNotes/SKNSkimReader.m 2023-11-29 16:35:30 UTC (rev 13814)
+++ trunk/SkimNotes/SKNSkimReader.m 2023-11-30 10:11:22 UTC (rev 13815)
@@ -59,28 +59,22 @@
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
[[NSNotificationCenter defaultCenter] removeObserver:self
name:NSConnectionDidDieNotification object:connection];
#pragma clang diagnostic pop
- [agent release];
agent = nil;
[[connection receivePort] invalidate];
[[connection sendPort] invalidate];
[connection invalidate];
- [connection release];
connection = nil;
}
- (void)dealloc {
- [[NSNotificationCenter defaultCenter] removeObserver:self];
[self destroyConnection];
- [agentIdentifier release];
- [super dealloc];
}
- (void)setAgentIdentifier:(NSString *)identifier {
NSAssert(connection == nil, @"agentIdentifier must be set before
connecting");
if (connection == nil && agentIdentifier != identifier) {
- [agentIdentifier release];
- agentIdentifier = [identifier retain];
+ agentIdentifier = identifier;
}
}
@@ -133,7 +127,7 @@
NSLog(@"failed to launch skimnotes agent: %@", exception);
taskLaunched = NO;
}
- [task release];
+ task = nil;
} else {
NSLog(@"failed to find skimnotes tool");
}
@@ -158,7 +152,7 @@
int maxTries = 5;
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
- connection = [[NSConnection connectionWithRegisteredName:[self
agentIdentifier] host:nil] retain];
+ connection = [NSConnection connectionWithRegisteredName:[self
agentIdentifier] host:nil];
#pragma clang diagnostic pop
// if we try to read data before the server is fully set up,
connection will still be nil
@@ -166,7 +160,7 @@
[NSThread sleepUntilDate:[NSDate
dateWithTimeIntervalSinceNow:0.1]];
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
- connection = [[NSConnection connectionWithRegisteredName:[self
agentIdentifier] host:nil] retain];
+ connection = [NSConnection connectionWithRegisteredName:[self
agentIdentifier] host:nil];
#pragma clang diagnostic pop
}
@@ -185,7 +179,7 @@
@try {
id server = [connection rootProxy];
[server
setProtocolForProxy:@protocol(SKNAgentListenerProtocol)];
- agent = [server retain];
+ agent = server;
}
@catch(id exception) {
NSLog(@"Error: exception \"%@\" caught when contacting
SkimNotesAgent", exception);
@@ -201,7 +195,7 @@
NSString *fileType = [ws typeOfFile:[fileURL path] error:NULL];
if (fileType != nil &&
- ([ws type:fileType conformsToType:(NSString *)kUTTypePDF] ||
+ ([ws type:fileType conformsToType:(__bridge NSString *)kUTTypePDF] ||
[ws type:fileType conformsToType:@"net.sourceforge.skim-app.pdfd"] ||
[ws type:fileType
conformsToType:@"net.sourceforge.skim-app.skimnotes"])) {
if (nil == connection)
@@ -253,7 +247,7 @@
[self destroyConnection];
}
}
- return textData ? [[[NSString alloc] initWithData:textData
encoding:NSUnicodeStringEncoding] autorelease] : nil;
+ return textData ? [[NSString alloc] initWithData:textData
encoding:NSUnicodeStringEncoding] : nil;
}
Modified: trunk/SkimNotes/SKNXPCSkimReader.m
===================================================================
--- trunk/SkimNotes/SKNXPCSkimReader.m 2023-11-29 16:35:30 UTC (rev 13814)
+++ trunk/SkimNotes/SKNXPCSkimReader.m 2023-11-30 10:11:22 UTC (rev 13815)
@@ -54,25 +54,20 @@
}
- (void)destroyConnection {
- [agent release];
agent = nil;
[connection invalidate];
- [connection release];
connection = nil;
}
- (void)dealloc {
[self destroyConnection];
- [agentIdentifier release];
- [super dealloc];
}
- (void)setAgentIdentifier:(NSString *)identifier {
NSAssert(connection == nil, @"agentIdentifier must be set before
connecting");
if (connection == nil && agentIdentifier != identifier) {
- [agentIdentifier release];
- agentIdentifier = [identifier retain];
+ agentIdentifier = identifier;
}
}
@@ -125,7 +120,7 @@
CFErrorRef removeError = NULL;
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
- if (false == SMJobRemove(kSMDomainUserLaunchd,
(CFStringRef)(label), auth, true, &removeError)) {
+ if (false == SMJobRemove(kSMDomainUserLaunchd, (__bridge
CFStringRef)(label), auth, true, &removeError)) {
#pragma clang diagnostic pop
if (removeError != NULL) {
// It's normal for a job to not be found, so this is not
an interesting error
@@ -142,7 +137,7 @@
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
// SMJobSubmit is deprecated but is the only way to submit a
non-permanent
// helper and allows us to submit to user domain without requiring
authorization
- if (SMJobSubmit(kSMDomainUserLaunchd,
(CFDictionaryRef)jobDictionary, auth, &submitError)) {
+ if (SMJobSubmit(kSMDomainUserLaunchd, (__bridge
CFDictionaryRef)jobDictionary, auth, &submitError)) {
#pragma clang diagnostic pop
taskLaunched = YES;
} else {
@@ -163,13 +158,14 @@
if ([self launchedTask]) {
connection = [[NSXPCConnection alloc] initWithMachServiceName:[self
agentIdentifier] options:0];
[connection setRemoteObjectInterface:[NSXPCInterface
interfaceWithProtocol:@protocol(SKNXPCAgentListenerProtocol)]];
+ __weak SKNXPCSkimReader *weakSelf = self;
[connection setInvalidationHandler:^{
- [self destroyConnection];
+ [weakSelf destroyConnection];
}];
if (sync)
- agent = [[connection
synchronousRemoteObjectProxyWithErrorHandler:^(NSError *error){}] retain];
+ agent = [connection
synchronousRemoteObjectProxyWithErrorHandler:^(NSError *error){}];
else
- agent = [[connection remoteObjectProxy] retain];
+ agent = [connection remoteObjectProxy];
synchronous = sync;
[connection resume];
}
@@ -186,7 +182,7 @@
NSString *fileType = [ws typeOfFile:[fileURL path] error:NULL];
if (fileType != nil &&
- ([ws type:fileType conformsToType:(NSString *)kUTTypePDF] ||
+ ([ws type:fileType conformsToType:(__bridge NSString *)kUTTypePDF] ||
[ws type:fileType conformsToType:@"net.sourceforge.skim-app.pdfd"] ||
[ws type:fileType
conformsToType:@"net.sourceforge.skim-app.skimnotes"])) {
if (nil == connection)
@@ -199,22 +195,22 @@
- (NSData *)SkimNotesAtURL:(NSURL *)fileURL {
__block NSData *data = nil;
if ([self connectAndCheckTypeOfFile:fileURL synchronous:YES])
- [agent readSkimNotesAtURL:fileURL reply:^(NSData *outData){ data =
[outData retain]; }];
- return [data autorelease];
+ [agent readSkimNotesAtURL:fileURL reply:^(NSData *outData){ data =
outData; }];
+ return data;
}
- (NSData *)RTFNotesAtURL:(NSURL *)fileURL {
__block NSData *data = nil;
if ([self connectAndCheckTypeOfFile:fileURL synchronous:YES])
- [agent readRTFNotesAtURL:fileURL reply:^(NSData *outData){ data =
[outData retain]; }];
- return [data autorelease];
+ [agent readRTFNotesAtURL:fileURL reply:^(NSData *outData){ data =
outData; }];
+ return data;
}
- (NSString *)textNotesAtURL:(NSURL *)fileURL {
__block NSString *string = nil;
if ([self connectAndCheckTypeOfFile:fileURL synchronous:YES])
- [agent readTextNotesAtURL:fileURL reply:^(NSString *outString){ string
= [outString retain]; }];
- return [string autorelease];
+ [agent readTextNotesAtURL:fileURL reply:^(NSString *outString){ string
= outString; }];
+ return string;
}
- (void)readSkimNotesAtURL:(NSURL *)fileURL reply:(void (^)(NSData *))reply {
Modified: trunk/SkimNotes/SkimNotes.xcodeproj/project.pbxproj
===================================================================
--- trunk/SkimNotes/SkimNotes.xcodeproj/project.pbxproj 2023-11-29 16:35:30 UTC
(rev 13814)
+++ trunk/SkimNotes/SkimNotes.xcodeproj/project.pbxproj 2023-11-30 10:11:22 UTC
(rev 13815)
@@ -1097,7 +1097,6 @@
CE665A860E1C086F00D0704D /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
- CLANG_ENABLE_OBJC_WEAK = YES;
PRODUCT_NAME = HeaderDocs;
};
name = Debug;
@@ -1105,7 +1104,6 @@
CE665A870E1C086F00D0704D /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
- CLANG_ENABLE_OBJC_WEAK = YES;
PRODUCT_NAME = HeaderDocs;
};
name = Release;
@@ -1141,7 +1139,6 @@
CEBA2EA30E0673B60000B2E6 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
- CLANG_ENABLE_OBJC_WEAK = YES;
PRODUCT_NAME = Archive;
};
name = Debug;
@@ -1149,7 +1146,6 @@
CEBA2EA40E0673B60000B2E6 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
- CLANG_ENABLE_OBJC_WEAK = YES;
PRODUCT_NAME = Archive;
};
name = Release;
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit