Skip to content
This repository has been archived by the owner on Mar 5, 2023. It is now read-only.

Commit

Permalink
Remove manual reference counting
Browse files Browse the repository at this point in the history
  • Loading branch information
Vadim Shpakovski committed Sep 4, 2016
1 parent 6667c9b commit 5cb6bc4
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 35 deletions.
6 changes: 3 additions & 3 deletions Framework/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.1.2</string>
<string>1.2</string>
<key>CFBundleVersion</key>
<string>1.1.2</string>
<string>120</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2014–2015 Vadim Shpakovski. All rights reserved.</string>
<string>Copyright © 2016 Vadim Shpakovski. All rights reserved.</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion Framework/MASPreferences.h
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#import "MASPreferencesViewController.h"
#import "MASPreferencesWindowController.h"
#import "MASPreferencesWindowController.h"
30 changes: 3 additions & 27 deletions Framework/MASPreferencesWindowController.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ @implementation MASPreferencesWindowController
@synthesize selectedViewController = _selectedViewController;
@synthesize title = _title;
@synthesize toolbar = _toolbar;

#pragma mark -

- (id)initWithViewControllers:(NSArray *)viewControllers
Expand All @@ -39,10 +40,7 @@ - (id)initWithViewControllers:(NSArray *)viewControllers title:(NSString *)title
NSString *nibPath = [[NSBundle bundleForClass:MASPreferencesWindowController.class] pathForResource:@"MASPreferencesWindow" ofType:@"nib"];
if ((self = [super initWithWindowNibPath:nibPath owner:self]))
{
_viewControllers = [NSMutableArray arrayWithArray: viewControllers];
#if !__has_feature(objc_arc)
_viewControllers = [_viewControllers retain];
#endif
_viewControllers = [viewControllers mutableCopy];
_minimumViewRects = [[NSMutableDictionary alloc] init];
_title = [title copy];
}
Expand All @@ -58,13 +56,6 @@ - (void)dealloc
item.action = nil;
}
self.toolbar.delegate = nil;
#if !__has_feature(objc_arc)
[_viewControllers release];
[_selectedViewController release];
[_minimumViewRects release];
[_title release];
[super dealloc];
#endif
}

- (void)addViewController: (NSViewController <MASPreferencesViewController> *) viewController
Expand Down Expand Up @@ -176,9 +167,6 @@ - (NSToolbarItem *)toolbar:(NSToolbar * __unused)toolbar itemForItemIdentifier:(
toolbarItem.target = self;
toolbarItem.action = @selector(toolbarItemDidClick:);
}
#if !__has_feature(objc_arc)
[toolbarItem autorelease];
#endif
return toolbarItem;
}

Expand Down Expand Up @@ -210,21 +198,12 @@ - (void)setSelectedViewController:(NSViewController <MASPreferencesViewControlle
[[self.window toolbar] setSelectedItemIdentifier:_selectedViewController.identifier];
return;
}

#if __has_feature(objc_arc)
[self.window setContentView:[[NSView alloc] init]];
#else
[self.window setContentView:[[[NSView alloc] init] autorelease]];
#endif
[_selectedViewController setNextResponder:nil];
// With 10.10 and later AppKit will invoke viewDidDisappear so we need to prevent it from being called twice.
if (![NSViewController instancesRespondToSelector:@selector(viewDidDisappear)])
if ([_selectedViewController respondsToSelector:@selector(viewDidDisappear)])
[_selectedViewController viewDidDisappear];

#if !__has_feature(objc_arc)
[_selectedViewController release];
#endif
_selectedViewController = nil;
}

Expand Down Expand Up @@ -278,11 +257,8 @@ - (void)setSelectedViewController:(NSViewController <MASPreferencesViewControlle

[self.window setFrame:newFrame display:YES animate:[self.window isVisible]];

#if __has_feature(objc_arc)
_selectedViewController = controller;
#else
_selectedViewController = [controller retain];
#endif

// In OSX 10.10, setContentView below calls viewWillAppear. We still want to call viewWillAppear on < 10.10,
// so the check below avoids calling viewWillAppear twice on 10.10.
// See https://github.com/shpakovski/MASPreferences/issues/32 for more info.
Expand Down
12 changes: 9 additions & 3 deletions MASPreferences.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
objects = {

/* Begin PBXBuildFile section */
F16AF8081BA27AFD0022155C /* MASPreferencesWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = F16AF8001BA27AFD0022155C /* MASPreferencesWindow.xib */; settings = {ASSET_TAGS = (); }; };
F16AF8081BA27AFD0022155C /* MASPreferencesWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = F16AF8001BA27AFD0022155C /* MASPreferencesWindow.xib */; };
F16AF80A1BA27AFD0022155C /* MASPreferences.h in Headers */ = {isa = PBXBuildFile; fileRef = F16AF8031BA27AFD0022155C /* MASPreferences.h */; settings = {ATTRIBUTES = (Public, ); }; };
F16AF80B1BA27AFD0022155C /* MASPreferencesViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = F16AF8051BA27AFD0022155C /* MASPreferencesViewController.h */; settings = {ATTRIBUTES = (Public, ); }; };
F16AF80C1BA27AFD0022155C /* MASPreferencesWindowController.h in Headers */ = {isa = PBXBuildFile; fileRef = F16AF8061BA27AFD0022155C /* MASPreferencesWindowController.h */; settings = {ATTRIBUTES = (Public, ); }; };
F16AF80D1BA27AFD0022155C /* MASPreferencesWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = F16AF8071BA27AFD0022155C /* MASPreferencesWindowController.m */; settings = {ASSET_TAGS = (); }; };
F16AF80D1BA27AFD0022155C /* MASPreferencesWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = F16AF8071BA27AFD0022155C /* MASPreferencesWindowController.m */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand Down Expand Up @@ -106,7 +106,7 @@
F16AF7EB1BA279F10022155C /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0700;
LastUpgradeCheck = 0800;
ORGANIZATIONNAME = "Vadim Shpakovski";
TargetAttributes = {
F16AF7F31BA279F10022155C = {
Expand Down Expand Up @@ -172,13 +172,16 @@
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
Expand Down Expand Up @@ -213,13 +216,16 @@
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0700"
LastUpgradeVersion = "0800"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down

0 comments on commit 5cb6bc4

Please sign in to comment.