1. Ivan Andrus
  2. sage-iphone-app

Commits

Ivan Andrus  committed 8534edf

Copy language when duplicating in main view

  • Participants
  • Parent commits 50fc9e3
  • Branches default

Comments (0)

Files changed (5)

File Classes/EditViewController.h

View file
  • Ignore whitespace
 - (IBAction)shareCell:(id)sender;
 - (void)selectLanguage:(id)sender;
 - (IBAction)newCell:(id)sender;
-- (void)newCellWithDefault:(NSString*)str;
-- (void)insertNewObjectWithString:(id)initial_value;
+- (void)newCellWithDefault:(AlephCell*)str;
 
 
 // Gesture actions (added programattically, but they could be IB actions)

File Classes/EditViewController.m

View file
  • Ignore whitespace
 #pragma mark -
 #pragma mark Button methods
 
-- (void)insertNewObjectWithString:(id)initial_value {
-    [self newCell:self];
+- (void)newCell:(id)sender {
+    [self.navigationController popViewControllerAnimated:NO];
+    [delegate editViewControllerDidFinish:self
+                              nextDefault:@""
+                               inLanguage:nil];
 }
 
-- (void)newCell:(id)sender {
-    [self newCellWithDefault:@""];
-}
-
-- (void)newCellWithDefault:(NSString*)str {
+- (void)newCellWithDefault:(AlephCell*)initial_value {
     if ( ![[selectedObject valueForKey:@"input"] isEqual:[inputView text]] ) {
         [selectedObject setValue:[inputView text] forKey:@"input"];
         [selectedObject setValue:[NSNumber numberWithInt:AlephCellStatusHasInput] forKey:@"status"];
 
     [self.navigationController popViewControllerAnimated:NO];
     [delegate editViewControllerDidFinish:self
-                              nextDefault:str
-                               inLanguage:([str isEqualToString:@""]
-                                           ? nil
-                                           : [selectedObject valueForKey:@"language"])];
+                              nextDefault:initial_value.input
+                               inLanguage:initial_value.language];
 }
 
 

File Classes/RootViewController.h

View file
  • Ignore whitespace
 
 - (void)insertNewObject;
 - (void)insertNewObjectWithString:(id)initial_value inLanguage:(id)lang;
-- (void)newCellWithDefault:(id)initial_value;
+- (void)newCellWithDefault:(AlephCell*)initial_value;
 
 - (void)editViewControllerDidFinish:(EditViewController *)controller nextDefault:(NSString*)str inLanguage:(NSString*)lang;
 - (void)editAlephCell:(NSManagedObject*)selectedObject;

File Classes/RootViewController.m

View file
  • Ignore whitespace
     [self insertNewObjectWithString:@"" inLanguage:nil];
 }
 
-- (void)newCellWithDefault:(id)initial_value {
-    [self insertNewObjectWithString:initial_value inLanguage:nil];
+- (void)newCellWithDefault:(AlephCell*)initial_value {
+    [self insertNewObjectWithString:initial_value.input
+                         inLanguage:initial_value.language];
 }
 
 - (void)insertNewObjectWithString:(id)initial_value inLanguage:(id)lang {

File Classes/ShareButtonDelegate.m

View file
  • Ignore whitespace
 
             case 0: // duplicate
                 [viewController performSelector:@selector(newCellWithDefault:)
-                                     withObject:cell.input
+                                     withObject:cell
                                      afterDelay:0];
                 break;