-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
308e4e6
commit c42aac8
Showing
22 changed files
with
1,824 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
BetteReddit.xcodeproj/project.xcworkspace/contents.xcworkspacedata
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
8 changes: 8 additions & 0 deletions
8
BetteReddit.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>IDEDidComputeMac32BitWarning</key> | ||
<true/> | ||
</dict> | ||
</plist> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
8 changes: 8 additions & 0 deletions
8
BetteReddit.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>IDEDidComputeMac32BitWarning</key> | ||
<true/> | ||
</dict> | ||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// | ||
// AppDelegate.h | ||
// BetteReddit | ||
// | ||
// Created by Alex Taffe on 5/27/18. | ||
// Copyright © 2018 Alex Taffe. All rights reserved. | ||
// | ||
|
||
#import <Cocoa/Cocoa.h> | ||
#import <CoreData/CoreData.h> | ||
|
||
@interface AppDelegate : NSObject <NSApplicationDelegate> | ||
|
||
@property (readonly, strong) NSPersistentContainer *persistentContainer; | ||
|
||
|
||
@end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
// | ||
// AppDelegate.m | ||
// BetteReddit | ||
// | ||
// Created by Alex Taffe on 5/27/18. | ||
// Copyright © 2018 Alex Taffe. All rights reserved. | ||
// | ||
|
||
#import "AppDelegate.h" | ||
|
||
@interface AppDelegate () | ||
|
||
- (IBAction)saveAction:(id)sender; | ||
|
||
@end | ||
|
||
@implementation AppDelegate | ||
|
||
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification { | ||
// Insert code here to initialize your application | ||
} | ||
|
||
|
||
- (void)applicationWillTerminate:(NSNotification *)aNotification { | ||
// Insert code here to tear down your application | ||
} | ||
|
||
|
||
#pragma mark - Core Data stack | ||
|
||
@synthesize persistentContainer = _persistentContainer; | ||
|
||
- (NSPersistentContainer *)persistentContainer { | ||
// The persistent container for the application. This implementation creates and returns a container, having loaded the store for the application to it. | ||
@synchronized (self) { | ||
if (_persistentContainer == nil) { | ||
_persistentContainer = [[NSPersistentContainer alloc] initWithName:@"BetteReddit"]; | ||
[_persistentContainer loadPersistentStoresWithCompletionHandler:^(NSPersistentStoreDescription *storeDescription, NSError *error) { | ||
if (error != nil) { | ||
// Replace this implementation with code to handle the error appropriately. | ||
// abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development. | ||
|
||
/* | ||
Typical reasons for an error here include: | ||
* The parent directory does not exist, cannot be created, or disallows writing. | ||
* The persistent store is not accessible, due to permissions or data protection when the device is locked. | ||
* The device is out of space. | ||
* The store could not be migrated to the current model version. | ||
Check the error message to determine what the actual problem was. | ||
*/ | ||
NSLog(@"Unresolved error %@, %@", error, error.userInfo); | ||
abort(); | ||
} | ||
}]; | ||
} | ||
} | ||
|
||
return _persistentContainer; | ||
} | ||
|
||
#pragma mark - Core Data Saving and Undo support | ||
|
||
- (IBAction)saveAction:(id)sender { | ||
// Performs the save action for the application, which is to send the save: message to the application's managed object context. Any encountered errors are presented to the user. | ||
NSManagedObjectContext *context = self.persistentContainer.viewContext; | ||
|
||
if (![context commitEditing]) { | ||
NSLog(@"%@:%@ unable to commit editing before saving", [self class], NSStringFromSelector(_cmd)); | ||
} | ||
|
||
NSError *error = nil; | ||
if (context.hasChanges && ![context save:&error]) { | ||
// Customize this code block to include application-specific recovery steps. | ||
[[NSApplication sharedApplication] presentError:error]; | ||
} | ||
} | ||
|
||
- (NSUndoManager *)windowWillReturnUndoManager:(NSWindow *)window { | ||
// Returns the NSUndoManager for the application. In this case, the manager returned is that of the managed object context for the application. | ||
return self.persistentContainer.viewContext.undoManager; | ||
} | ||
|
||
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender { | ||
// Save changes in the application's managed object context before the application terminates. | ||
NSManagedObjectContext *context = self.persistentContainer.viewContext; | ||
|
||
if (![context commitEditing]) { | ||
NSLog(@"%@:%@ unable to commit editing to terminate", [self class], NSStringFromSelector(_cmd)); | ||
return NSTerminateCancel; | ||
} | ||
|
||
if (!context.hasChanges) { | ||
return NSTerminateNow; | ||
} | ||
|
||
NSError *error = nil; | ||
if (![context save:&error]) { | ||
|
||
// Customize this code block to include application-specific recovery steps. | ||
BOOL result = [sender presentError:error]; | ||
if (result) { | ||
return NSTerminateCancel; | ||
} | ||
|
||
NSString *question = NSLocalizedString(@"Could not save changes while quitting. Quit anyway?", @"Quit without saves error question message"); | ||
NSString *info = NSLocalizedString(@"Quitting now will lose any changes you have made since the last successful save", @"Quit without saves error question info"); | ||
NSString *quitButton = NSLocalizedString(@"Quit anyway", @"Quit anyway button title"); | ||
NSString *cancelButton = NSLocalizedString(@"Cancel", @"Cancel button title"); | ||
NSAlert *alert = [[NSAlert alloc] init]; | ||
[alert setMessageText:question]; | ||
[alert setInformativeText:info]; | ||
[alert addButtonWithTitle:quitButton]; | ||
[alert addButtonWithTitle:cancelButton]; | ||
|
||
NSInteger answer = [alert runModal]; | ||
|
||
if (answer == NSAlertSecondButtonReturn) { | ||
return NSTerminateCancel; | ||
} | ||
} | ||
|
||
return NSTerminateNow; | ||
} | ||
|
||
@end |
58 changes: 58 additions & 0 deletions
58
BetteReddit/Assets.xcassets/AppIcon.appiconset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "mac", | ||
"size" : "16x16", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"size" : "16x16", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"size" : "32x32", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"size" : "32x32", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"size" : "128x128", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"size" : "128x128", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"size" : "256x256", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"size" : "256x256", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"size" : "512x512", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"size" : "512x512", | ||
"scale" : "2x" | ||
} | ||
], | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
Oops, something went wrong.