2
0

Improved cloud store enumeration.

[ADDED]     Stores now enumerated in a TVC.
This commit is contained in:
Maarten Billemont 2013-09-07 10:08:49 -04:00
parent 0921796136
commit 8ea0f00cf0
3 changed files with 17 additions and 23 deletions

2
External/Pearl vendored

@ -1 +1 @@
Subproject commit 41c3582a72ddb251b9a3a055ecdad3fa49ec18f2
Subproject commit ea7054e328bd7162d1f5a56a0f64a3eed6e3fc66

@ -1 +1 @@
Subproject commit ebc094f4c160f8aa3ebbe3f760fbf734b58bc5e6
Subproject commit 5a19df087f7a694ad6427708f6d23c62ad8999bb

View File

@ -91,8 +91,8 @@
for (NSURL *content in contents)
if ([[NSFileManager defaultManager] fileExistsAtPath:content.path isDirectory:&directory] && directory) {
NSString *contentString = [content lastPathComponent];
NSUInteger lastDash = [contentString rangeOfString:@"-" options:NSBackwardsSearch].location;
NSString *storeDescription = lastDash == NSNotFound? contentString: [contentString substringFromIndex:lastDash + 1];
NSUInteger firstDash = [contentString rangeOfString:@"-" options:0].location;
NSString *storeDescription = firstDash == NSNotFound? contentString: [contentString substringToIndex:firstDash];
NSPersistentStore *store = nil;
@try {
NSURL *storeURL = [[cloudStoreDirectory
@ -135,27 +135,21 @@
}
NSString *storeUUID = [[MPiOSAppDelegate get].storeManager valueForKey:@"storeUUID_ThreadSafe"];
NSUInteger lastDash = [storeUUID rangeOfString:@"-" options:NSBackwardsSearch].location;
NSString *title = PearlString( @"Current: %@", lastDash == NSNotFound? storeUUID: [storeUUID substringFromIndex:lastDash + 1] );
NSUInteger firstDash = [storeUUID rangeOfString:@"-" options:0].location;
PearlArrayTVC *vc = [[PearlArrayTVC alloc] initWithStyle:UITableViewStylePlain];
vc.title = PearlString( @"Current: %@", firstDash == NSNotFound? storeUUID: [storeUUID substringToIndex:firstDash] );
[stores enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
[vc addRowWithName:obj style:PearlArrayTVCRowStyleLink toggled:NO toSection:@"Cloud Stores"
activationBlock:^BOOL(BOOL wasToggled) {
[[MPiOSAppDelegate get].storeManager setValue:key forKey:@"storeUUID"];
[[MPiOSAppDelegate get].storeManager reloadStore];
[[MPiOSAppDelegate get] signOutAnimated:YES];
return YES;
}];
}];
dispatch_async( dispatch_get_main_queue(), ^{
[switchCloudStoreProgress cancelAlertAnimated:YES];
NSArray *storeUUIDs = [stores allKeys];
[PearlSheet showSheetWithTitle:title viewStyle:UIActionSheetStyleAutomatic
initSheet:^(UIActionSheet *sheet) {
for (NSString *contentName in storeUUIDs)
[sheet addButtonWithTitle:[stores objectForKey:contentName]];
}
tappedButtonBlock:^(UIActionSheet *sheet, NSInteger buttonIndex) {
if (buttonIndex == sheet.cancelButtonIndex)
return;
[[MPiOSAppDelegate get].storeManager setValue:[storeUUIDs objectAtIndex:(unsigned)buttonIndex]
forKey:@"storeUUID"];
[[MPiOSAppDelegate get].storeManager reloadStore];
[[MPiOSAppDelegate get] signOutAnimated:YES];
}
cancelTitle:[PearlStrings get].commonButtonCancel destructiveTitle:nil otherTitles:nil];
[self.navigationController pushViewController:vc animated:YES];
} );
}