diff --git a/LaunchAtLoginController.m b/LaunchAtLoginController.m index 7148dbe..4f2c86c 100644 --- a/LaunchAtLoginController.m +++ b/LaunchAtLoginController.m @@ -37,7 +37,7 @@ @implementation LaunchAtLoginController void sharedFileListDidChange(LSSharedFileListRef inList, void *context) { - LaunchAtLoginController *self = (id) context; + LaunchAtLoginController *self = (__bridge id) context; [self willChangeValueForKey:StartAtLoginKey]; [self didChangeValueForKey:StartAtLoginKey]; } @@ -46,19 +46,18 @@ void sharedFileListDidChange(LSSharedFileListRef inList, void *context) - (id) init { - [super init]; + self = [super init]; loginItems = LSSharedFileListCreate(NULL, kLSSharedFileListSessionLoginItems, NULL); LSSharedFileListAddObserver(loginItems, CFRunLoopGetMain(), - (CFStringRef)NSDefaultRunLoopMode, sharedFileListDidChange, self); + (CFStringRef)NSDefaultRunLoopMode, sharedFileListDidChange, (voidPtr)CFBridgingRetain(self)); return self; } - (void) dealloc { LSSharedFileListRemoveObserver(loginItems, CFRunLoopGetMain(), - (CFStringRef)NSDefaultRunLoopMode, sharedFileListDidChange, self); + (CFStringRef)NSDefaultRunLoopMode, sharedFileListDidChange, (__bridge void *)(self)); CFRelease(loginItems); - [super dealloc]; } #pragma mark Launch List Control @@ -68,13 +67,14 @@ - (LSSharedFileListItemRef) findItemWithURL: (NSURL*) wantedURL inFileList: (LSS if (wantedURL == NULL || fileList == NULL) return NULL; - NSArray *listSnapshot = [NSMakeCollectable(LSSharedFileListCopySnapshot(fileList, NULL)) autorelease]; + NSArray *listSnapshot = (__bridge NSArray *)(LSSharedFileListCopySnapshot(fileList, NULL)); for (id itemObject in listSnapshot) { - LSSharedFileListItemRef item = (LSSharedFileListItemRef) itemObject; + LSSharedFileListItemRef item = (__bridge LSSharedFileListItemRef) itemObject; UInt32 resolutionFlags = kLSSharedFileListNoUserInteraction | kLSSharedFileListDoNotMountVolumes; CFURLRef currentItemURL = NULL; LSSharedFileListItemResolve(item, resolutionFlags, ¤tItemURL, NULL); - if (currentItemURL && CFEqual(currentItemURL, wantedURL)) { + if (currentItemURL && CFEqual(currentItemURL, (__bridge CFTypeRef)(wantedURL))) + { CFRelease(currentItemURL); return item; } @@ -95,7 +95,7 @@ - (void) setLaunchAtLogin: (BOOL) enabled forURL: (NSURL*) itemURL LSSharedFileListItemRef appItem = [self findItemWithURL:itemURL inFileList:loginItems]; if (enabled && !appItem) { LSSharedFileListInsertItemURL(loginItems, kLSSharedFileListItemBeforeFirst, - NULL, NULL, (CFURLRef)itemURL, NULL, NULL); + NULL, NULL, (__bridge CFURLRef)itemURL, NULL, NULL); } else if (!enabled && appItem) LSSharedFileListItemRemove(loginItems, appItem); }