• R/O
  • HTTP
  • SSH
  • HTTPS

Tombo: Commit

TOMBO source code


Commit MetaInfo

Revision89ce2e318d0cd125e449f946c72ccd9ea3667cb1 (tree)
Time2012-03-31 08:59:40
AuthorHirami <tomohisa.hirami@nift...>
CommiterHirami

Log Message

Don't save when no text is modified.

Change Summary

Incremental Difference

--- a/iOS/Tombo/Tombo/DetailViewController.h
+++ b/iOS/Tombo/Tombo/DetailViewController.h
@@ -2,7 +2,7 @@
22 #import "FileItem.h"
33 #import "Storage.h"
44
5-@interface DetailViewController : UIViewController <UISplitViewControllerDelegate>
5+@interface DetailViewController : UIViewController <UISplitViewControllerDelegate,UITextViewDelegate>
66
77 @property (strong, nonatomic) FileItem *detailItem;
88 @property (strong, nonatomic) Storage *storage;
--- a/iOS/Tombo/Tombo/DetailViewController.m
+++ b/iOS/Tombo/Tombo/DetailViewController.m
@@ -1,7 +1,9 @@
11 #import "DetailViewController.h"
22 #import "MasterViewController.h"
33
4-@interface DetailViewController ()
4+@interface DetailViewController () {
5+ BOOL isModify;
6+}
57 @property (strong, nonatomic) UIPopoverController *masterPopoverController;
68 - (void)configureView;
79 @end
@@ -59,7 +61,9 @@
5961 name:UIKeyboardDidHideNotification
6062 object:nil];
6163
64+ self.detailText.delegate = self;
6265 [self configureView];
66+ isModify = NO;
6367 }
6468
6569 - (void)viewDidUnload
@@ -72,21 +76,22 @@
7276
7377 - (void)viewWillDisappear:(BOOL)animated {
7478 // Leaving detail view
75- NSString *note = self.detailText.text;
76-
77- FileItem *newPath = [storage save:note item: self.detailItem];
78-
79- // To notify master view, retract reference from navigation controller.
80- MasterViewController *master = [self.navigationController.viewControllers objectAtIndex:0];
81-
82- if (self.detailItem.name) {
83- // item exists
84- if (self.detailItem != newPath) {
85- [master itemChanged: self.detailItem to:newPath];
79+ if (isModify) {
80+ NSString *note = self.detailText.text;
81+ FileItem *newPath = [storage save:note item: self.detailItem];
82+
83+ // To notify master view, retract reference from navigation controller.
84+ MasterViewController *master = [self.navigationController.viewControllers objectAtIndex:0];
85+
86+ if (self.detailItem.name) {
87+ // item exists
88+ if (self.detailItem != newPath) {
89+ [master itemChanged: self.detailItem to:newPath];
90+ }
91+ } else {
92+ // new item
93+ [master itemAdded: newPath];
8694 }
87- } else {
88- // new item
89- [master itemAdded: newPath];
9095 }
9196
9297 [super viewWillDisappear: animated];
@@ -101,6 +106,10 @@
101106 }
102107 }
103108
109+- (void)textViewDidChange:(UITextView *)textView {
110+ isModify = YES;
111+}
112+
104113 #pragma mark - Notification handler
105114
106115 - (void)keyboardDidShow:(NSNotification*)notification {
Show on old repository browser