diff --git a/McBopomofo.xcodeproj/project.pbxproj b/McBopomofo.xcodeproj/project.pbxproj
index 72c1d809..bd16df99 100644
--- a/McBopomofo.xcodeproj/project.pbxproj
+++ b/McBopomofo.xcodeproj/project.pbxproj
@@ -821,6 +821,7 @@
ALWAYS_SEARCH_USER_PATHS = NO;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
+ CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_IMPLICIT_SIGN_CONVERSION = NO;
@@ -872,6 +873,7 @@
ALWAYS_SEARCH_USER_PATHS = NO;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
+ CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_IMPLICIT_SIGN_CONVERSION = NO;
diff --git a/McBopomofo.xcodeproj/xcshareddata/xcschemes/McBopomofo.xcscheme b/McBopomofo.xcodeproj/xcshareddata/xcschemes/McBopomofo.xcscheme
new file mode 100644
index 00000000..56d01ed8
--- /dev/null
+++ b/McBopomofo.xcodeproj/xcshareddata/xcschemes/McBopomofo.xcscheme
@@ -0,0 +1,78 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Source/AppDelegate.h b/Source/AppDelegate.h
index 56778c6d..96ee6e0c 100644
--- a/Source/AppDelegate.h
+++ b/Source/AppDelegate.h
@@ -39,7 +39,6 @@
@interface AppDelegate : NSObject
{
@private
- NSWindow *_window;
NSURLConnection *_updateCheckConnection;
BOOL _currentUpdateCheckIsForced;
NSMutableData *_receivingData;
@@ -51,5 +50,5 @@
- (void)checkForUpdateForced:(BOOL)forced;
- (void)showPreferences;
-@property (assign, nonatomic) IBOutlet NSWindow *window;
+@property (weak, nonatomic) IBOutlet NSWindow *window;
@end
diff --git a/Source/AppDelegate.m b/Source/AppDelegate.m
index 409d9d84..cc6b896c 100644
--- a/Source/AppDelegate.m
+++ b/Source/AppDelegate.m
@@ -53,9 +53,8 @@ static const NSTimeInterval kTimeoutInterval = 60.0;
- (void)dealloc
{
- [_preferencesWindowController release];
- [_updateCheckConnection release];
- [super dealloc];
+ _preferencesWindowController = nil;
+ _updateCheckConnection = nil;
}
- (void)applicationDidFinishLaunching:(NSNotification *)inNotification
@@ -124,7 +123,6 @@ static const NSTimeInterval kTimeoutInterval = 60.0;
#endif
if (_receivingData) {
- [_receivingData release];
_receivingData = nil;
}
@@ -147,9 +145,7 @@ static const NSTimeInterval kTimeoutInterval = 60.0;
{
BOOL isForcedCheck = _currentUpdateCheckIsForced;
- [_receivingData release];
_receivingData = nil;
- [_updateCheckConnection release];
_updateCheckConnection = nil;
_currentUpdateCheckIsForced = NO;
@@ -172,9 +168,7 @@ static const NSTimeInterval kTimeoutInterval = 60.0;
BOOL isForcedCheck = _currentUpdateCheckIsForced;
- [_receivingData release];
_receivingData = nil;
- [_updateCheckConnection release];
_updateCheckConnection = nil;
_currentUpdateCheckIsForced = NO;
@@ -226,9 +220,7 @@ static const NSTimeInterval kTimeoutInterval = 60.0;
}
return;
}
- [_updateNextStepURL release];
- _updateNextStepURL = nil;
- _updateNextStepURL = [siteInfoURL retain];
+ _updateNextStepURL = siteInfoURL;
NSDictionary *versionDescriptions = [plist objectForKey:@"Description"];
NSString *versionDescription = @"";
@@ -268,13 +260,11 @@ static const NSTimeInterval kTimeoutInterval = 60.0;
[[NSWorkspace sharedWorkspace] openURL:_updateNextStepURL];
}
- [_updateNextStepURL release];
_updateNextStepURL = nil;
}
- (void)nonModalAlertWindowControllerDidCancel:(OVNonModalAlertWindowController *)controller
{
- [_updateNextStepURL release];
_updateNextStepURL = nil;
}
diff --git a/Source/CandidateUI/VTCandidateController.h b/Source/CandidateUI/VTCandidateController.h
index 2518f1bb..41e36a5c 100644
--- a/Source/CandidateUI/VTCandidateController.h
+++ b/Source/CandidateUI/VTCandidateController.h
@@ -56,7 +56,7 @@
- (NSUInteger)candidateIndexAtKeyLabelIndex:(NSUInteger)index;
-@property (assign, weak, nonatomic) id delegate;
+@property (weak, nonatomic) id delegate;
@property (assign, nonatomic) NSUInteger selectedCandidateIndex;
@property (assign, nonatomic) BOOL visible;
diff --git a/Source/CandidateUI/VTCandidateController.m b/Source/CandidateUI/VTCandidateController.m
index c7db63d9..5605ff71 100644
--- a/Source/CandidateUI/VTCandidateController.m
+++ b/Source/CandidateUI/VTCandidateController.m
@@ -36,10 +36,9 @@
- (void)dealloc
{
- [_keyLabels release];
- [_keyLabelFont release];
- [_candidateFont release];
- [super dealloc];
+ _keyLabels = nil;
+ _keyLabelFont = nil;
+ _candidateFont = nil;
}
- (id)initWithWindow:(NSWindow *)window
@@ -47,11 +46,10 @@
self = [super initWithWindow:window];
if (self) {
// populate the default values
- _keyLabels = [[NSArray arrayWithObjects:@"1", @"2", @"3", @"4", @"5", @"6", @"7", @"8", @"9", nil] retain];
- _keyLabelFont = [[NSFont systemFontOfSize:14.0] retain];
- _candidateFont = [[NSFont systemFontOfSize:18.0] retain];
+ _keyLabels = @[@"1", @"2", @"3", @"4", @"5", @"6", @"7", @"8", @"9"];
+ _keyLabelFont = [NSFont systemFontOfSize:14.0];
+ _candidateFont = [NSFont systemFontOfSize:18.0];
}
-
return self;
}
diff --git a/Source/CandidateUI/VTHorizontalCandidateController.m b/Source/CandidateUI/VTHorizontalCandidateController.m
index f69affdd..4cc8795b 100644
--- a/Source/CandidateUI/VTHorizontalCandidateController.m
+++ b/Source/CandidateUI/VTHorizontalCandidateController.m
@@ -40,10 +40,9 @@
- (void)dealloc
{
- [_candidateView release];
- [_prevPageButton release];
- [_nextPageButton release];
- [super dealloc];
+ _candidateView = nil;
+ _prevPageButton = nil;
+ _nextPageButton = nil;
}
- (id)init
@@ -51,7 +50,7 @@
NSRect contentRect = NSMakeRect(128.0, 128.0, 0.0, 0.0);
NSUInteger styleMask = NSBorderlessWindowMask | NSNonactivatingPanelMask;
- NSPanel *panel = [[[NSPanel alloc] initWithContentRect:contentRect styleMask:styleMask backing:NSBackingStoreBuffered defer:NO] autorelease];
+ NSPanel *panel = [[NSPanel alloc] initWithContentRect:contentRect styleMask:styleMask backing:NSBackingStoreBuffered defer:NO];
[panel setLevel:kCGPopUpMenuWindowLevel];
[panel setHasShadow:YES];
diff --git a/Source/CandidateUI/VTHorizontalCandidateView.h b/Source/CandidateUI/VTHorizontalCandidateView.h
index c5295503..492b7c5c 100644
--- a/Source/CandidateUI/VTHorizontalCandidateView.h
+++ b/Source/CandidateUI/VTHorizontalCandidateView.h
@@ -50,5 +50,5 @@
@property (readonly, nonatomic) NSSize sizeForView;
@property (assign, nonatomic) NSUInteger highlightedIndex;
@property (assign, nonatomic) SEL action;
-@property (weak, assign, nonatomic) id target;
+@property (weak, nonatomic) id target;
@end
diff --git a/Source/CandidateUI/VTHorizontalCandidateView.m b/Source/CandidateUI/VTHorizontalCandidateView.m
index 461ecc10..d24122f5 100644
--- a/Source/CandidateUI/VTHorizontalCandidateView.m
+++ b/Source/CandidateUI/VTHorizontalCandidateView.m
@@ -39,26 +39,18 @@ NS_INLINE CGFloat max(CGFloat a, CGFloat b) { return a > b ? a : b; }
- (void)dealloc
{
- [_keyLabels release];
- [_displayedCandidates release];
- [_keyLabelAttrDict release];
- [_candidateAttrDict release];
- [_elementWidths release];
- [super dealloc];
+ _keyLabels = nil;
+ _displayedCandidates = nil;
+ _keyLabelAttrDict = nil;
+ _candidateAttrDict = nil;
+ _elementWidths = nil;
}
- (void)setKeyLabels:(NSArray *)labels displayedCandidates:(NSArray *)candidates
{
NSUInteger count = min([labels count], [candidates count]);
- id tmp;
-
- tmp = _keyLabels;
- _keyLabels = [[labels subarrayWithRange:NSMakeRange(0, count)] retain];
- [tmp release];
-
- tmp = _displayedCandidates;
- _displayedCandidates = [[candidates subarrayWithRange:NSMakeRange(0, count)] retain];
- [tmp release];
+ _keyLabels = [labels subarrayWithRange:NSMakeRange(0, count)];
+ _displayedCandidates = [candidates subarrayWithRange:NSMakeRange(0, count)];
NSMutableArray *newWidths = [NSMutableArray array];
@@ -71,33 +63,25 @@ NS_INLINE CGFloat max(CGFloat a, CGFloat b) { return a > b ? a : b; }
CGFloat width = max(labelRect.size.width, candidateRect.size.width) + _cellPadding;
[newWidths addObject:[NSNumber numberWithDouble:width]];
}
-
- tmp = _elementWidths;
- _elementWidths = [newWidths retain];
- [tmp release];
+
+ _elementWidths = newWidths;
}
- (void)setKeyLabelFont:(NSFont *)labelFont candidateFont:(NSFont *)candidateFont
{
- NSMutableParagraphStyle *paraStyle = [[[NSParagraphStyle defaultParagraphStyle] mutableCopy] autorelease];
+ NSMutableParagraphStyle *paraStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
[paraStyle setAlignment:NSCenterTextAlignment];
-
- id tmp;
- tmp = _keyLabelAttrDict;
- _keyLabelAttrDict = [[NSDictionary dictionaryWithObjectsAndKeys:
+
+ _keyLabelAttrDict = [NSDictionary dictionaryWithObjectsAndKeys:
labelFont, NSFontAttributeName,
paraStyle, NSParagraphStyleAttributeName,
[NSColor blackColor], NSForegroundColorAttributeName,
- nil] retain];
- [tmp release];
-
- tmp = _candidateAttrDict;
- _candidateAttrDict = [[NSDictionary dictionaryWithObjectsAndKeys:
+ nil];
+ _candidateAttrDict = [NSDictionary dictionaryWithObjectsAndKeys:
candidateFont, NSFontAttributeName,
paraStyle, NSParagraphStyleAttributeName,
[NSColor textColor], NSForegroundColorAttributeName,
- nil] retain];
- [tmp release];
+ nil];
CGFloat labelFontSize = [labelFont pointSize];
CGFloat candidateFontSize = [candidateFont pointSize];
@@ -165,7 +149,7 @@ NS_INLINE CGFloat max(CGFloat a, CGFloat b) { return a > b ? a : b; }
if (index == _highlightedIndex) {
[[NSColor selectedTextBackgroundColor] setFill];
- activeCandidateAttr = [[_candidateAttrDict mutableCopy] autorelease];
+ activeCandidateAttr = [_candidateAttrDict mutableCopy];
[(NSMutableDictionary *)activeCandidateAttr setObject:[NSColor selectedTextColor] forKey:NSForegroundColorAttributeName];
}
else {
@@ -230,9 +214,12 @@ NS_INLINE CGFloat max(CGFloat a, CGFloat b) { return a > b ? a : b; }
_trackingHighlightedIndex = 0;
[self setNeedsDisplay:YES];
+# pragma clang diagnostic push
+# pragma clang diagnostic ignored "-Warc-performSelector-leaks"
if (triggerAction && _target && _action) {
[_target performSelector:_action withObject:self];
}
+# pragma clang diagnostic pop
}
@end
diff --git a/Source/CandidateUI/VTVerticalCandidateController.m b/Source/CandidateUI/VTVerticalCandidateController.m
index 03e555cf..7150d45b 100644
--- a/Source/CandidateUI/VTVerticalCandidateController.m
+++ b/Source/CandidateUI/VTVerticalCandidateController.m
@@ -57,21 +57,13 @@ static const CGFloat kCandidateTextLeftMarginWithMandatedTableViewPadding = 0.0;
CGFloat _candidateTextLeftMargin;
}
-- (void)dealloc
-{
- [_candidateTextParagraphStyle release];
- [_keyLabelStripView release];
- [_scrollView release];
- [_tableView release];
- [super dealloc];
-}
- (id)init
{
NSRect contentRect = NSMakeRect(128.0, 128.0, 0.0, 0.0);
NSUInteger styleMask = NSBorderlessWindowMask | NSNonactivatingPanelMask;
- NSPanel *panel = [[[NSPanel alloc] initWithContentRect:contentRect styleMask:styleMask backing:NSBackingStoreBuffered defer:NO] autorelease];
+ NSPanel *panel = [[NSPanel alloc] initWithContentRect:contentRect styleMask:styleMask backing:NSBackingStoreBuffered defer:NO];
[panel setLevel:kCGPopUpMenuWindowLevel];
[panel setHasShadow:YES];
@@ -100,8 +92,8 @@ static const CGFloat kCandidateTextLeftMarginWithMandatedTableViewPadding = 0.0;
[_tableView setDataSource:self];
[_tableView setDelegate:self];
- NSTableColumn *column = [[[NSTableColumn alloc] initWithIdentifier:@"candidate"] autorelease];
- [column setDataCell:[[[NSTextFieldCell alloc] init] autorelease]];
+ NSTableColumn *column = [[NSTableColumn alloc] initWithIdentifier:@"candidate"];
+ [column setDataCell:[[NSTextFieldCell alloc] init]];
[column setEditable:NO];
_candidateTextPadding = kCandidateTextPadding;
@@ -238,7 +230,7 @@ static const CGFloat kCandidateTextLeftMarginWithMandatedTableViewPadding = 0.0;
candidate = [_delegate candidateController:self candidateAtIndex:row];
}
- NSAttributedString *attrString = [[[NSAttributedString alloc] initWithString:candidate attributes:[NSDictionary dictionaryWithObjectsAndKeys:_candidateFont, NSFontAttributeName, _candidateTextParagraphStyle, NSParagraphStyleAttributeName, nil]] autorelease];
+ NSAttributedString *attrString = [[NSAttributedString alloc] initWithString:candidate attributes:[NSDictionary dictionaryWithObjectsAndKeys:_candidateFont, NSFontAttributeName, _candidateTextParagraphStyle, NSParagraphStyleAttributeName, nil]];
// we do more work than what this method is expected to; normally not a good practice, but for the amount of data (9 to 10 rows max), we can afford the overhead
diff --git a/Source/CandidateUI/VTVerticalKeyLabelStripView.m b/Source/CandidateUI/VTVerticalKeyLabelStripView.m
index b6514421..1a7d2a19 100644
--- a/Source/CandidateUI/VTVerticalKeyLabelStripView.m
+++ b/Source/CandidateUI/VTVerticalKeyLabelStripView.m
@@ -35,9 +35,8 @@
- (void)dealloc
{
- [_keyLabelFont release];
- [_keyLabels release];
- [super dealloc];
+ _keyLabelFont = nil;
+ _keyLabels = nil;
}
- (id)initWithFrame:(NSRect)frameRect
@@ -71,7 +70,7 @@
NSColor *darkGray = [NSColor colorWithDeviceWhite:0.7 alpha:1.0];
NSColor *lightGray = [NSColor colorWithDeviceWhite:0.8 alpha:1.0];
- NSMutableParagraphStyle *style = [[[NSParagraphStyle defaultParagraphStyle] mutableCopy] autorelease];
+ NSMutableParagraphStyle *style = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
[style setAlignment:NSCenterTextAlignment];
NSDictionary *textAttr = [NSDictionary dictionaryWithObjectsAndKeys:
diff --git a/Source/InputMethodController.mm b/Source/InputMethodController.mm
index de92a3b5..052ff8b0 100644
--- a/Source/InputMethodController.mm
+++ b/Source/InputMethodController.mm
@@ -160,14 +160,11 @@ public:
delete _builder;
}
- [_composingBuffer release];
- [_candidates release];
// the two client pointers are weak pointers (i.e. we don't retain them)
// therefore we don't do anything about it
- [super dealloc];
}
- (id)initWithServer:(IMKServer *)server delegate:(id)delegate client:(id)client
@@ -206,8 +203,8 @@ public:
- (NSMenu *)menu
{
// a menu instance (autoreleased) is requested every time the user click on the input menu
- NSMenu *menu = [[[NSMenu alloc] initWithTitle:LocalizationNotNeeded(@"Input Method Menu")] autorelease];
- NSMenuItem *preferenceMenuItem = [[[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"McBopomofo Preferences", @"") action:@selector(showPreferences:) keyEquivalent:@""] autorelease];
+ NSMenu *menu = [[NSMenu alloc] initWithTitle:LocalizationNotNeeded(@"Input Method Menu")];
+ NSMenuItem *preferenceMenuItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"McBopomofo Preferences", @"") action:@selector(showPreferences:) keyEquivalent:@""];
[menu addItem:preferenceMenuItem];
// If Option key is pressed, show the learning-related menu
@@ -218,7 +215,7 @@ public:
BOOL learningEnabled = ![[NSUserDefaults standardUserDefaults] boolForKey:kDisableUserCandidateSelectionLearning];
- NSMenuItem *learnMenuItem = [[[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Enable Selection Learning", @"") action:@selector(toggleLearning:) keyEquivalent:@""] autorelease];
+ NSMenuItem *learnMenuItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Enable Selection Learning", @"") action:@selector(toggleLearning:) keyEquivalent:@""];
if (learningEnabled) {
[learnMenuItem setState:NSOnState];
}
@@ -230,20 +227,20 @@ public:
if (learningEnabled) {
NSString *clearMenuItemTitle = [NSString stringWithFormat:NSLocalizedString(@"Clear Learning Dictionary (%ju Items)", @""), (uintmax_t)[gCandidateLearningDictionary count]];
- NSMenuItem *clearMenuItem = [[[NSMenuItem alloc] initWithTitle:clearMenuItemTitle action:@selector(clearLearningDictionary:) keyEquivalent:@""] autorelease];
+ NSMenuItem *clearMenuItem = [[NSMenuItem alloc] initWithTitle:clearMenuItemTitle action:@selector(clearLearningDictionary:) keyEquivalent:@""];
[menu addItem:clearMenuItem];
- NSMenuItem *dumpMenuItem = [[[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Dump Learning Data to Console", @"") action:@selector(dumpLearningDictionary:) keyEquivalent:@""] autorelease];
+ NSMenuItem *dumpMenuItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Dump Learning Data to Console", @"") action:@selector(dumpLearningDictionary:) keyEquivalent:@""];
[menu addItem:dumpMenuItem];
}
}
#endif //DEBUG
- NSMenuItem *updateCheckItem = [[[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Check for Updates…", @"") action:@selector(checkForUpdate:) keyEquivalent:@""] autorelease];
+ NSMenuItem *updateCheckItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Check for Updates…", @"") action:@selector(checkForUpdate:) keyEquivalent:@""];
[menu addItem:updateCheckItem];
- NSMenuItem *aboutMenuItem = [[[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"About McBopomofo…", @"") action:@selector(showAbout:) keyEquivalent:@""] autorelease];
+ NSMenuItem *aboutMenuItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"About McBopomofo…", @"") action:@selector(showAbout:) keyEquivalent:@""];
[menu addItem:aboutMenuItem];
return menu;
@@ -464,7 +461,7 @@ public:
NSDictionary *attrDict = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithInt:NSUnderlineStyleSingle], NSUnderlineStyleAttributeName,
[NSNumber numberWithInt:0], NSMarkedClauseSegmentAttributeName, nil];
- NSMutableAttributedString *attrString = [[[NSMutableAttributedString alloc] initWithString:composedText attributes:attrDict] autorelease];
+ NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc] initWithString:composedText attributes:attrDict];
// the selection range is where the cursor is, with the length being 0 and replacement range NSNotFound,
// i.e. the client app needs to take care of where to put ths composing buffer
@@ -1540,7 +1537,7 @@ void LTLoadLanguageModel()
// TODO: Change this
NSString *userDictFile = [userDictPath stringByAppendingPathComponent:@"UserCandidatesCache.plist"];
- gUserCandidatesDictionaryPath = [userDictFile retain];
+ gUserCandidatesDictionaryPath = userDictFile;
exists = [[NSFileManager defaultManager] fileExistsAtPath:userDictFile isDirectory:&isDir];
if (exists && !isDir) {
diff --git a/Source/OVInputSourceHelper.m b/Source/OVInputSourceHelper.m
index 33ffe703..d9815879 100644
--- a/Source/OVInputSourceHelper.m
+++ b/Source/OVInputSourceHelper.m
@@ -31,7 +31,8 @@
+ (NSArray *)allInstalledInputSources
{
CFArrayRef list = TISCreateInputSourceList(NULL, true);
- return [NSMakeCollectable(list) autorelease];
+ return (__bridge NSArray *)list;
+// return [NSMakeCollectable(list) autorelease];
}
+ (TISInputSourceRef)inputSourceForProperty:(CFStringRef)inPropertyKey stringValue:(NSString *)inValue
@@ -39,16 +40,15 @@
CFTypeID stringID = CFStringGetTypeID();
for (id source in [self allInstalledInputSources]) {
- CFTypeRef property = TISGetInputSourceProperty((TISInputSourceRef)source, inPropertyKey);
+ CFTypeRef property = TISGetInputSourceProperty((__bridge TISInputSourceRef)source, inPropertyKey);
if (!property || CFGetTypeID(property) != stringID) {
continue;
}
- if (inValue && [inValue compare:(NSString *)property] == NSOrderedSame) {
- return (TISInputSourceRef)source;
+ if (inValue && [inValue compare:(__bridge NSString *)property] == NSOrderedSame) {
+ return (__bridge TISInputSourceRef)source;
}
}
-
return NULL;
}
@@ -74,9 +74,9 @@
BOOL enabled = NO;
for (id source in [self allInstalledInputSources]) {
- TISInputSourceRef inputSource = (TISInputSourceRef)source;
- NSString *bundleID = (NSString *)TISGetInputSourceProperty(inputSource, kTISPropertyBundleID);
- NSString *mode = (NSString *)TISGetInputSourceProperty(inputSource, kTISPropertyInputModeID);
+ TISInputSourceRef inputSource = (__bridge TISInputSourceRef)source;
+ NSString *bundleID = (__bridge NSString *)TISGetInputSourceProperty(inputSource, kTISPropertyBundleID);
+ NSString *mode = (NSString *)CFBridgingRelease(TISGetInputSourceProperty(inputSource, kTISPropertyInputModeID));
if (mode && [bundleID isEqualToString:inID]) {
BOOL modeEnabled = [self enableInputSource:inputSource];
if (!modeEnabled) {
@@ -98,7 +98,7 @@
+ (BOOL)registerInputSource:(NSURL *)inBundleURL
{
- OSStatus status = TISRegisterInputSource((CFURLRef)inBundleURL);
+ OSStatus status = TISRegisterInputSource((__bridge CFURLRef)inBundleURL);
return status == noErr;
}
@end
diff --git a/Source/OVNonModalAlertWindowController.h b/Source/OVNonModalAlertWindowController.h
index 6ca4902b..91453cb8 100644
--- a/Source/OVNonModalAlertWindowController.h
+++ b/Source/OVNonModalAlertWindowController.h
@@ -20,11 +20,11 @@
@interface OVNonModalAlertWindowController : NSWindowController
{
@private
- NSTextField *_titleTextField;
- NSTextField *_contentTextField;
- NSButton *_confirmButton;
- NSButton *_cancelButton;
- id _delegate;
+// NSTextField *_titleTextField;
+// NSTextField *_contentTextField;
+// NSButton *_confirmButton;
+// NSButton *_cancelButton;
+// id _delegate;
}
+ (OVNonModalAlertWindowController *)sharedInstance;
diff --git a/Source/PreferencesWindowController.h b/Source/PreferencesWindowController.h
index 7ca3afd7..345ea254 100644
--- a/Source/PreferencesWindowController.h
+++ b/Source/PreferencesWindowController.h
@@ -36,10 +36,10 @@
@interface PreferencesWindowController : NSWindowController
{
@private
- NSPopUpButton *_fontSizePopUpButton;
- NSPopUpButton *_basisKeyboardLayoutButton;
+ NSPopUpButton *__weak _fontSizePopUpButton;
+ NSPopUpButton *__weak _basisKeyboardLayoutButton;
}
- (IBAction)updateBasisKeyboardLayoutAction:(id)sender;
-@property (assign, nonatomic) IBOutlet NSPopUpButton *fontSizePopUpButton;
-@property (assign, nonatomic) IBOutlet NSPopUpButton *basisKeyboardLayoutButton;
+@property (weak, nonatomic) IBOutlet NSPopUpButton *fontSizePopUpButton;
+@property (weak, nonatomic) IBOutlet NSPopUpButton *basisKeyboardLayoutButton;
@end
diff --git a/Source/PreferencesWindowController.m b/Source/PreferencesWindowController.m
index 8fc7a134..668bfb54 100644
--- a/Source/PreferencesWindowController.m
+++ b/Source/PreferencesWindowController.m
@@ -68,10 +68,10 @@ static NSString *const kBasisKeyboardLayoutPreferenceKey = @"BasisKeyboardLayout
continue;
}
- NSString *sourceID = (NSString *)TISGetInputSourceProperty(source, kTISPropertyInputSourceID);
- NSString *localizedName = (NSString *)TISGetInputSourceProperty(source, kTISPropertyLocalizedName);
+ NSString *sourceID = (__bridge NSString *)TISGetInputSourceProperty(source, kTISPropertyInputSourceID);
+ NSString *localizedName = (__bridge NSString *)TISGetInputSourceProperty(source, kTISPropertyLocalizedName);
- NSMenuItem *item = [[[NSMenuItem alloc] init] autorelease];
+ NSMenuItem *item = [[NSMenuItem alloc] init];
[item setTitle:localizedName];
[item setRepresentedObject:sourceID];
diff --git a/Source/main.m b/Source/main.m
index 3920834f..bca49bd0 100644
--- a/Source/main.m
+++ b/Source/main.m
@@ -39,7 +39,7 @@ static NSString *const kConnectionName = @"McBopomofo_1_Connection";
int main(int argc, char *argv[])
{
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ @autoreleasepool {
// register and enable the input source (along with all its input modes)
if (argc > 1 && !strcmp(argv[1], "install")) {
@@ -64,7 +64,6 @@ int main(int argc, char *argv[])
if (!status) {
NSLog(@"Fatal error: Cannot register input source %@ at %@.", bundleID, [bundleURL absoluteString]);
- [pool drain];
return -1;
}
@@ -72,7 +71,6 @@ int main(int argc, char *argv[])
// if it still doesn't register successfully, bail.
if (!inputSource) {
NSLog(@"Fatal error: Cannot find input source %@ after registration.", bundleID);
- [pool drain];
return -1;
}
}
@@ -84,12 +82,10 @@ int main(int argc, char *argv[])
if (!status) {
NSLog(@"Fatal error: Cannot enable input source %@.", bundleID);
- [pool drain];
return -1;
}
if (![OVInputSourceHelper inputSourceEnabled:inputSource]){
NSLog(@"Fatal error: Cannot enable input source %@.", bundleID);
- [pool drain];
return -1;
}
}
@@ -110,26 +106,22 @@ int main(int argc, char *argv[])
NSString *mainNibName = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"NSMainNibFile"];
if (!mainNibName) {
NSLog(@"Fatal error: NSMainNibFile key not defined in Info.plist.");
- [pool drain];
return -1;
}
BOOL loadResult = [[NSBundle mainBundle] loadNibNamed:mainNibName owner:[NSApplication sharedApplication] topLevelObjects:NULL];
if (!loadResult) {
NSLog(@"Fatal error: Cannot load %@.", mainNibName);
- [pool drain];
return -1;
}
IMKServer *server = [[IMKServer alloc] initWithName:kConnectionName bundleIdentifier:[[NSBundle mainBundle] bundleIdentifier]];
if (!server) {
NSLog(@"Fatal error: Cannot initialize input method server with connection %@.", kConnectionName);
- [pool drain];
return -1;
}
[[NSApplication sharedApplication] run];
- [server release];
- [pool drain];
+ }
return 0;
}