Skip to content

Commit bc94512

Browse files
committed
ARC
1 parent fd4f80d commit bc94512

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+764
-2937
lines changed

ApplicationController.m

Lines changed: 40 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,24 @@
1616
#import "PBNSURLPathUserDefaultsTransfomer.h"
1717
#import "PBGitDefaults.h"
1818

19+
20+
1921
@implementation ApplicationController
2022

21-
- (ApplicationController*)init
22-
{
23+
- (ApplicationController *)init {
2324
#ifdef DEBUG_BUILD
2425
[NSApp activateIgnoringOtherApps:YES];
2526
#endif
2627

27-
if(!(self = [super init]))
28-
return nil;
29-
30-
if(![[NSBundle bundleWithPath:@"/System/Library/Frameworks/Quartz.framework/Frameworks/QuickLookUI.framework"] load])
31-
if(![[NSBundle bundleWithPath:@"/System/Library/PrivateFrameworks/QuickLookUI.framework"] load])
32-
NSLog(@"Could not load QuickLook");
28+
if (self = [super init]) {
29+
if (![[NSBundle bundleWithPath:@"/System/Library/Frameworks/Quartz.framework/Frameworks/QuickLookUI.framework"] load])
30+
if (![[NSBundle bundleWithPath:@"/System/Library/PrivateFrameworks/QuickLookUI.framework"] load])
31+
NSLog(@"Could not load QuickLook");
3332

34-
/* Value Transformers */
35-
NSValueTransformer *transformer = [[PBNSURLPathUserDefaultsTransfomer alloc] init];
36-
[NSValueTransformer setValueTransformer:transformer forName:@"PBNSURLPathUserDefaultsTransfomer"];
37-
38-
// Make sure the PBGitDefaults is initialized, by calling a random method
39-
[PBGitDefaults class];
33+
[NSValueTransformer setValueTransformer:[PBNSURLPathUserDefaultsTransfomer new] forName:@"PBNSURLPathUserDefaultsTransfomer"];
34+
35+
[PBGitDefaults class]; // Make sure the PBGitDefaults is initialized, by calling a random method
36+
}
4037
return self;
4138
}
4239

@@ -101,9 +98,9 @@ - (void)applicationDidFinishLaunching:(NSNotification*)notification
10198
[[PBRepositoryDocumentController sharedDocumentController] openDocument:self];
10299
}
103100

104-
- (void) windowWillClose: sender
101+
- (void)windowWillClose:sender
105102
{
106-
[firstResponder terminate: sender];
103+
[firstResponder terminate:sender];
107104
}
108105

109106
- (IBAction)openPreferencesWindow:(id)sender
@@ -167,125 +164,60 @@ - (IBAction)installCliTool:(id)sender;
167164
}
168165
}
169166

170-
/**
171-
Returns the support folder for the application, used to store the Core Data
172-
store file. This code uses a folder named "GitTest" for
173-
the content, either in the NSApplicationSupportDirectory location or (if the
174-
former cannot be found), the system's temporary directory.
175-
*/
176-
177167
- (NSString *)applicationSupportFolder {
178168

179169
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
180170
NSString *basePath = ([paths count] > 0) ? [paths objectAtIndex:0] : NSTemporaryDirectory();
181171
return [basePath stringByAppendingPathComponent:@"GitTest"];
182172
}
183173

184-
185-
/**
186-
Creates, retains, and returns the managed object model for the application
187-
by merging all of the models found in the application bundle.
188-
*/
189-
190174
- (NSManagedObjectModel *)managedObjectModel {
191-
192-
if (managedObjectModel != nil) {
193-
return managedObjectModel;
194-
}
195-
196-
managedObjectModel = [[NSManagedObjectModel mergedModelFromBundles:nil] retain];
197-
return managedObjectModel;
175+
return managedObjectModel ?: (managedObjectModel = [NSManagedObjectModel mergedModelFromBundles:nil]);
198176
}
199177

200-
201-
/**
202-
Returns the persistent store coordinator for the application. This
203-
implementation will create and return a coordinator, having added the
204-
store for the application to it. (The folder for the store is created,
205-
if necessary.)
206-
*/
207-
208178
- (NSPersistentStoreCoordinator *) persistentStoreCoordinator {
209-
210-
if (persistentStoreCoordinator != nil) {
211-
return persistentStoreCoordinator;
212-
}
213-
214-
NSFileManager *fileManager;
215-
NSString *applicationSupportFolder = nil;
216-
NSURL *url;
217-
NSError *error;
218-
219-
fileManager = [NSFileManager defaultManager];
220-
applicationSupportFolder = [self applicationSupportFolder];
221-
if ( ![fileManager fileExistsAtPath:applicationSupportFolder isDirectory:NULL] ) {
222-
[fileManager createDirectoryAtPath:applicationSupportFolder withIntermediateDirectories:YES attributes:nil error:nil];
179+
if (!persistentStoreCoordinator) {
180+
NSFileManager *fileManager;
181+
NSString *applicationSupportFolder = nil;
182+
NSURL *url;
183+
NSError *error;
184+
185+
fileManager = [NSFileManager defaultManager];
186+
applicationSupportFolder = [self applicationSupportFolder];
187+
if ( ![fileManager fileExistsAtPath:applicationSupportFolder isDirectory:NULL] ) {
188+
[fileManager createDirectoryAtPath:applicationSupportFolder withIntermediateDirectories:YES attributes:nil error:nil];
189+
}
190+
191+
url = [NSURL fileURLWithPath: [applicationSupportFolder stringByAppendingPathComponent: @"GitTest.xml"]];
192+
persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel: [self managedObjectModel]];
193+
if (![persistentStoreCoordinator addPersistentStoreWithType:NSXMLStoreType configuration:nil URL:url options:nil error:&error]){
194+
[[NSApplication sharedApplication] presentError:error];
195+
}
223196
}
224-
225-
url = [NSURL fileURLWithPath: [applicationSupportFolder stringByAppendingPathComponent: @"GitTest.xml"]];
226-
persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel: [self managedObjectModel]];
227-
if (![persistentStoreCoordinator addPersistentStoreWithType:NSXMLStoreType configuration:nil URL:url options:nil error:&error]){
228-
[[NSApplication sharedApplication] presentError:error];
229-
}
230197

231198
return persistentStoreCoordinator;
232199
}
233200

234-
235-
/**
236-
Returns the managed object context for the application (which is already
237-
bound to the persistent store coordinator for the application.)
238-
*/
239-
240201
- (NSManagedObjectContext *) managedObjectContext {
241-
242-
if (managedObjectContext != nil) {
243-
return managedObjectContext;
244-
}
245-
246-
NSPersistentStoreCoordinator *coordinator = [self persistentStoreCoordinator];
247-
if (coordinator != nil) {
248-
managedObjectContext = [[NSManagedObjectContext alloc] init];
249-
[managedObjectContext setPersistentStoreCoordinator: coordinator];
202+
if (!managedObjectContext) {
203+
managedObjectContext = [NSManagedObjectContext new];
204+
managedObjectContext.persistentStoreCoordinator = self.persistentStoreCoordinator;
250205
}
251-
252206
return managedObjectContext;
253207
}
254208

255-
256-
/**
257-
Returns the NSUndoManager for the application. In this case, the manager
258-
returned is that of the managed object context for the application.
259-
*/
260-
261209
- (NSUndoManager *)windowWillReturnUndoManager:(NSWindow *)window {
262-
return [[self managedObjectContext] undoManager];
210+
return self.managedObjectContext.undoManager;
263211
}
264-
265-
266-
/**
267-
Performs the save action for the application, which is to send the save:
268-
message to the application's managed object context. Any encountered errors
269-
are presented to the user.
270-
*/
271212

272213
- (IBAction) saveAction:(id)sender {
273-
274-
NSError *error = nil;
214+
id error = nil;
275215
if (![[self managedObjectContext] save:&error]) {
276-
[[NSApplication sharedApplication] presentError:error];
216+
[NSApp presentError:error];
277217
}
278218
}
279219

280-
281-
/**
282-
Implementation of the applicationShouldTerminate: method, used here to
283-
handle the saving of changes in the application managed object context
284-
before the application terminates.
285-
*/
286-
287220
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender {
288-
289221
NSError *error;
290222
int reply = NSTerminateNow;
291223

@@ -348,10 +280,9 @@ - (void)applicationWillTerminate:(NSNotification *)aNotification
348280

349281
- (void) dealloc {
350282

351-
[managedObjectContext release], managedObjectContext = nil;
352-
[persistentStoreCoordinator release], persistentStoreCoordinator = nil;
353-
[managedObjectModel release], managedObjectModel = nil;
354-
[super dealloc];
283+
managedObjectContext = nil;
284+
persistentStoreCoordinator = nil;
285+
managedObjectModel = nil;
355286
}
356287

357288
#pragma mark Help menu

DBPrefsWindowController.m

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,14 @@ - (void)windowDidLoad
7474
// Create a new window to display the preference views.
7575
// If the developer attached a window to this controller
7676
// in Interface Builder, it gets replaced with this one.
77-
NSPanel *panel = [[[NSPanel alloc] initWithContentRect:NSMakeRect(0,0,1000,1000)
77+
NSPanel *panel = [[NSPanel alloc] initWithContentRect:NSMakeRect(0,0,1000,1000)
7878
styleMask:(NSTitledWindowMask |
7979
NSClosableWindowMask |
8080
NSMiniaturizableWindowMask)
8181
backing:NSBackingStoreBuffered
82-
defer:YES] autorelease];
82+
defer:YES];
8383
[self setWindow:panel];
84-
contentSubview = [[[NSView alloc] initWithFrame:[[[self window] contentView] frame]] autorelease];
84+
contentSubview = [[NSView alloc] initWithFrame:[[[self window] contentView] frame]];
8585
[contentSubview setAutoresizingMask:(NSViewMinYMargin | NSViewWidthSizable)];
8686
[[[self window] contentView] addSubview:contentSubview];
8787
[[self window] setShowsToolbarButton:NO];
@@ -90,13 +90,6 @@ - (void)windowDidLoad
9090

9191

9292

93-
- (void) dealloc {
94-
[toolbarIdentifiers release];
95-
[toolbarViews release];
96-
[toolbarItems release];
97-
[viewAnimation release];
98-
[super dealloc];
99-
}
10093

10194

10295

@@ -129,12 +122,12 @@ - (void)addView:(NSView *)view label:(NSString *)label image:(NSImage *)image
129122
NSAssert (view != nil,
130123
@"Attempted to add a nil view when calling -addView:label:image:.");
131124

132-
NSString *identifier = [[label copy] autorelease];
125+
NSString *identifier = [label copy];
133126

134127
[toolbarIdentifiers addObject:identifier];
135128
[toolbarViews setObject:view forKey:identifier];
136129

137-
NSToolbarItem *item = [[[NSToolbarItem alloc] initWithItemIdentifier:identifier] autorelease];
130+
NSToolbarItem *item = [[NSToolbarItem alloc] initWithItemIdentifier:identifier];
138131
[item setLabel:label];
139132
[item setImage:image];
140133
[item setTarget:self];
@@ -208,7 +201,6 @@ - (IBAction)showWindow:(id)sender
208201
[toolbar setDisplayMode:NSToolbarDisplayModeIconAndLabel];
209202
[toolbar setDelegate:self];
210203
[[self window] setToolbar:toolbar];
211-
[toolbar release];
212204
}
213205

214206
NSString *identifier = [self defaultViewIdentifier];

English.lproj/MainMenu.xib

Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="8.00">
33
<data>
44
<int key="IBDocument.SystemTarget">1070</int>
5-
<string key="IBDocument.SystemVersion">11D50b</string>
6-
<string key="IBDocument.InterfaceBuilderVersion">2182</string>
7-
<string key="IBDocument.AppKitVersion">1138.32</string>
8-
<string key="IBDocument.HIToolboxVersion">568.00</string>
5+
<string key="IBDocument.SystemVersion">12A269</string>
6+
<string key="IBDocument.InterfaceBuilderVersion">2549</string>
7+
<string key="IBDocument.AppKitVersion">1187</string>
8+
<string key="IBDocument.HIToolboxVersion">624.00</string>
99
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
1010
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string>
11-
<string key="NS.object.0">2182</string>
11+
<string key="NS.object.0">2549</string>
1212
</object>
1313
<array key="IBDocument.IntegratedClassDependencies">
14-
<string>NSUserDefaultsController</string>
14+
<string>NSCustomObject</string>
1515
<string>NSMenu</string>
1616
<string>NSMenuItem</string>
17-
<string>NSCustomObject</string>
17+
<string>NSUserDefaultsController</string>
1818
</array>
1919
<array key="IBDocument.PluginDependencies">
2020
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
@@ -938,9 +938,6 @@
938938
<object class="NSUserDefaultsController" id="391227374">
939939
<bool key="NSSharedInstance">YES</bool>
940940
</object>
941-
<object class="NSCustomObject" id="203602687">
942-
<string key="NSClassName">SUUpdater</string>
943-
</object>
944941
</array>
945942
<object class="IBObjectContainer" key="IBDocument.Objects">
946943
<array class="NSMutableArray" key="connectionRecords">
@@ -1376,14 +1373,6 @@
13761373
</object>
13771374
<int key="connectionID">973</int>
13781375
</object>
1379-
<object class="IBConnectionRecord">
1380-
<object class="IBActionConnection" key="connection">
1381-
<string key="label">checkForUpdates:</string>
1382-
<reference key="source" ref="203602687"/>
1383-
<reference key="destination" ref="679871620"/>
1384-
</object>
1385-
<int key="connectionID">920</int>
1386-
</object>
13871376
</array>
13881377
<object class="IBMutableOrderedSet" key="objectRecords">
13891378
<array key="orderedObjects">
@@ -1977,11 +1966,6 @@
19771966
<reference key="object" ref="552718495"/>
19781967
<reference key="parent" ref="245837913"/>
19791968
</object>
1980-
<object class="IBObjectRecord">
1981-
<int key="objectID">918</int>
1982-
<reference key="object" ref="203602687"/>
1983-
<reference key="parent" ref="0"/>
1984-
</object>
19851969
<object class="IBObjectRecord">
19861970
<int key="objectID">919</int>
19871971
<reference key="object" ref="679871620"/>
@@ -2169,7 +2153,6 @@
21692153
<string key="912.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
21702154
<string key="915.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
21712155
<string key="916.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
2172-
<string key="918.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
21732156
<string key="919.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
21742157
<string key="927.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
21752158
<string key="928.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
@@ -2235,10 +2218,6 @@
22352218
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.macosx</string>
22362219
<real value="1070" key="NS.object.0"/>
22372220
</object>
2238-
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencyDefaults">
2239-
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.macosx</string>
2240-
<real value="1070" key="NS.object.0"/>
2241-
</object>
22422221
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies">
22432222
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3</string>
22442223
<real value="4300" key="NS.object.0"/>

English.lproj/PBRemoteProgressSheet.xib

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353
<int key="NSvFlags">1314</int>
5454
<string key="NSFrame">{{18, 16}, {361, 20}}</string>
5555
<reference key="NSSuperview" ref="1006"/>
56-
<reference key="NSNextKeyView"/>
5756
<int key="NSpiFlags">16394</int>
5857
<double key="NSMaxValue">100</double>
5958
</object>

GLFileView.h

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)