Permalink
Browse files

Cope gracefully with not being in a sandbox.

  • Loading branch information...
1 parent 8bfe0fe commit cd14754d5b715cc12dfd75facc826e7c8bbace79 @beelsebob committed Dec 24, 2012
Showing with 17 additions and 10 deletions.
  1. +17 −10 Stash/STAAppDelegate.m
View
27 Stash/STAAppDelegate.m
@@ -247,11 +247,15 @@ - (IBAction)addDocumentation:(id)sender
includingResourceValuesForKeys:@[]
relativeToURL:nil
error:&err];
- NSArray *documentationBookmarks = [[NSUserDefaults standardUserDefaults] arrayForKey:STADocumentationBookmarksKey];
- documentationBookmarks = documentationBookmarks ? : @[];
- documentationBookmarks = [documentationBookmarks containsObject:bookmark] ? documentationBookmarks : [documentationBookmarks arrayByAddingObject:bookmark];
- [[NSUserDefaults standardUserDefaults] setObject:documentationBookmarks forKey:STADocumentationBookmarksKey];
- [[NSUserDefaults standardUserDefaults] synchronize];
+ if (nil != bookmark)
+ {
+ NSArray *documentationBookmarks = [[NSUserDefaults standardUserDefaults] arrayForKey:STADocumentationBookmarksKey];
+ documentationBookmarks = documentationBookmarks ? : @[];
+ documentationBookmarks = [documentationBookmarks containsObject:bookmark] ? documentationBookmarks : [documentationBookmarks arrayByAddingObject:bookmark];
+ [[NSUserDefaults standardUserDefaults] setObject:documentationBookmarks forKey:STADocumentationBookmarksKey];
+ [[NSUserDefaults standardUserDefaults] synchronize];
+ }
+ [self indexDocsetsWithPermissionInRoots:@[lastRoot] withContinuation:^(){}];
});
}];
}
@@ -370,11 +374,14 @@ - (void)indexDocsetsInRoots:(NSArray *)originalRoots index:(NSUInteger)idx selec
includingResourceValuesForKeys:@[]
relativeToURL:nil
error:&err];
- NSArray *documentationBookmarks = [[NSUserDefaults standardUserDefaults] arrayForKey:STADocumentationBookmarksKey];
- documentationBookmarks = documentationBookmarks ? : @[];
- documentationBookmarks = [documentationBookmarks containsObject:bookmark] ? documentationBookmarks : [documentationBookmarks arrayByAddingObject:bookmark];
- [[NSUserDefaults standardUserDefaults] setObject:documentationBookmarks forKey:STADocumentationBookmarksKey];
- [[NSUserDefaults standardUserDefaults] synchronize];
+ if (nil != bookmark)
+ {
+ NSArray *documentationBookmarks = [[NSUserDefaults standardUserDefaults] arrayForKey:STADocumentationBookmarksKey];
+ documentationBookmarks = documentationBookmarks ? : @[];
+ documentationBookmarks = [documentationBookmarks containsObject:bookmark] ? documentationBookmarks : [documentationBookmarks arrayByAddingObject:bookmark];
+ [[NSUserDefaults standardUserDefaults] setObject:documentationBookmarks forKey:STADocumentationBookmarksKey];
+ [[NSUserDefaults standardUserDefaults] synchronize];
+ }
[self indexDocsetsInRoots:originalRoots index:idx+1 selectedRoots:[selectedRoots arrayByAddingObject:selectedRoot] withContinuation:cont];
});

0 comments on commit cd14754

Please sign in to comment.