diff -ru -x 'MemoDatesIcon*' -x '*~' -x '*.xcdatamodeld' -x '*.xcodeproj' -x '*.xib' -x build MemoDates+CoreData/Classes/AddViewController.h MemoDates/Classes/AddViewController.h
--- MemoDates+CoreData/Classes/AddViewController.h	2011-01-28 20:25:46.000000000 +0900
+++ MemoDates/Classes/AddViewController.h	2011-01-28 20:27:21.000000000 +0900
@@ -7,10 +7,18 @@
 //
 
 #import <UIKit/UIKit.h>
+#import "DetailViewController.h"
 
+@protocol AddViewControllerDelegate;
 
-@interface AddViewController : UIViewController {
-
+@interface AddViewController : DetailViewController {
+  id <AddViewControllerDelegate> delegate;
 }
 
+@property (nonatomic, assign) id <AddViewControllerDelegate> delegate;
+
+@end
+
+@protocol AddViewControllerDelegate
+- (void)addViewController:(AddViewController *)controller didFinishWithSave:(BOOL)save;
 @end
diff -ru -x 'MemoDatesIcon*' -x '*~' -x '*.xcdatamodeld' -x '*.xcodeproj' -x '*.xib' -x build MemoDates+CoreData/Classes/AddViewController.m MemoDates/Classes/AddViewController.m
--- MemoDates+CoreData/Classes/AddViewController.m	2011-01-28 20:25:46.000000000 +0900
+++ MemoDates/Classes/AddViewController.m	2011-01-28 21:56:14.000000000 +0900
@@ -11,6 +11,8 @@
 
 @implementation AddViewController
 
+@synthesize delegate;
+
 // The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
 /*
 - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
@@ -28,12 +30,20 @@
 }
 */
 
-/*
 // Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
 - (void)viewDidLoad {
     [super viewDidLoad];
+  self.title = @"New MemoDate";
+  self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel 
+                                                                                         target:self action:@selector(cancel:)] autorelease];
+  self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSave 
+                                                                                          target:self action:@selector(save:)] autorelease];
+  
+#if defined(ENABLE_UNDO_EDITING)
+  [self setUpUndoManager];
+#endif
+  self.editing = YES;
 }
-*/
 
 /*
 // Override to allow orientations other than the default portrait orientation.
@@ -54,12 +64,20 @@
     [super viewDidUnload];
     // Release any retained subviews of the main view.
     // e.g. self.myOutlet = nil;
+#if defined(ENABLE_UNDO_EDITING)
+  [self cleanUpUndoManager];
+#endif
 }
 
+- (IBAction)cancel:(id)sender {
+  [delegate addViewController:self didFinishWithSave:NO];
+}
+- (IBAction)save:(id)sender {
+  [delegate addViewController:self didFinishWithSave:YES];
+}
 
 - (void)dealloc {
     [super dealloc];
 }
 
-
 @end
diff -ru -x 'MemoDatesIcon*' -x '*~' -x '*.xcdatamodeld' -x '*.xcodeproj' -x '*.xib' -x build MemoDates+CoreData/Classes/CategoryEditingViewController.h MemoDates/Classes/CategoryEditingViewController.h
--- MemoDates+CoreData/Classes/CategoryEditingViewController.h	2011-01-28 20:18:00.000000000 +0900
+++ MemoDates/Classes/CategoryEditingViewController.h	2011-01-28 20:30:08.000000000 +0900
@@ -7,10 +7,11 @@
 //
 
 #import <UIKit/UIKit.h>
+#import "EditingViewController.h"
 
 
-@interface CategoryEditingViewController : UIViewController {
-
+@interface CategoryEditingViewController : EditingViewController {
+  IBOutlet UITextField *textField;
 }
 
 @end
diff -ru -x 'MemoDatesIcon*' -x '*~' -x '*.xcdatamodeld' -x '*.xcodeproj' -x '*.xib' -x build MemoDates+CoreData/Classes/CategoryEditingViewController.m MemoDates/Classes/CategoryEditingViewController.m
--- MemoDates+CoreData/Classes/CategoryEditingViewController.m	2011-01-28 20:18:00.000000000 +0900
+++ MemoDates/Classes/CategoryEditingViewController.m	2011-01-28 22:01:29.000000000 +0900
@@ -22,12 +22,17 @@
 }
 */
 
-/*
 // Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
 - (void)viewDidLoad {
     [super viewDidLoad];
+    self.title = @"Category";
+}
+
+- (void)viewWillAppear:(BOOL)animated {
+  [super viewWillAppear:animated];
+  textField.text = [editedObject valueForKey:@"category"];
+  [textField becomeFirstResponder];
 }
-*/
 
 /*
 // Override to allow orientations other than the default portrait orientation.
@@ -50,6 +55,17 @@
     // e.g. self.myOutlet = nil;
 }
 
+- (IBAction)cancel:(id)sender {
+  [super cancel:sender];
+}
+- (IBAction)save:(id)sender {
+#if defined(ENABLE_UNDO_EDITING)
+  NSUndoManager *undoManager = [[editedObject managedObjectContext] undoManager];
+  [undoManager setActionName:[NSString stringWithFormat:@"%@", self.title]];
+#endif  
+  [editedObject setValue:textField.text forKey:@"category"];
+  [super save:sender];
+}
 
 - (void)dealloc {
     [super dealloc];
diff -ru -x 'MemoDatesIcon*' -x '*~' -x '*.xcdatamodeld' -x '*.xcodeproj' -x '*.xib' -x build MemoDates+CoreData/Classes/DateEditingViewController.h MemoDates/Classes/DateEditingViewController.h
--- MemoDates+CoreData/Classes/DateEditingViewController.h	2011-01-28 20:18:18.000000000 +0900
+++ MemoDates/Classes/DateEditingViewController.h	2011-01-28 20:32:09.000000000 +0900
@@ -7,10 +7,10 @@
 //
 
 #import <UIKit/UIKit.h>
+#import "EditingViewController.h"
 
-
-@interface DateEditingViewController : UIViewController {
-
+@interface DateEditingViewController : EditingViewController {
+  IBOutlet UIDatePicker *datePicker;
 }
 
 @end
diff -ru -x 'MemoDatesIcon*' -x '*~' -x '*.xcdatamodeld' -x '*.xcodeproj' -x '*.xib' -x build MemoDates+CoreData/Classes/DateEditingViewController.m MemoDates/Classes/DateEditingViewController.m
--- MemoDates+CoreData/Classes/DateEditingViewController.m	2011-01-28 20:18:18.000000000 +0900
+++ MemoDates/Classes/DateEditingViewController.m	2011-01-28 22:01:38.000000000 +0900
@@ -22,12 +22,16 @@
 }
 */
 
-/*
 // Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
 - (void)viewDidLoad {
     [super viewDidLoad];
+    self.title = @"Date";
+}
+
+- (void)viewWillAppear:(BOOL)animated {
+  [super viewWillAppear:animated];
+  datePicker.date = [editedObject valueForKey:@"date"];
 }
-*/
 
 /*
 // Override to allow orientations other than the default portrait orientation.
@@ -50,6 +54,17 @@
     // e.g. self.myOutlet = nil;
 }
 
+- (IBAction)cancel:(id)sender {
+  [super cancel:sender];
+}
+- (IBAction)save:(id)sender {
+#if defined(ENABLE_UNDO_EDITING)
+  NSUndoManager *undoManager = [[editedObject managedObjectContext] undoManager];
+  [undoManager setActionName:[NSString stringWithFormat:@"%@", self.title]];  
+#endif  
+  [editedObject setValue:datePicker.date forKey:@"date"];
+  [super save:sender];
+}
 
 - (void)dealloc {
     [super dealloc];
diff -ru -x 'MemoDatesIcon*' -x '*~' -x '*.xcdatamodeld' -x '*.xcodeproj' -x '*.xib' -x build MemoDates+CoreData/Classes/DetailViewController.h MemoDates/Classes/DetailViewController.h
--- MemoDates+CoreData/Classes/DetailViewController.h	2011-01-28 20:15:57.000000000 +0900
+++ MemoDates/Classes/DetailViewController.h	2011-01-28 20:33:59.000000000 +0900
@@ -10,7 +10,20 @@
 
 
 @interface DetailViewController : UITableViewController {
-
+  UISwitch *notifiableSwitch;
+  NSManagedObject *selectedObject;
+#if defined(ENABLE_UNDO_EDITING)
+  NSUndoManager *undoManager;
+#endif
 }
 
+@property (nonatomic, retain) UISwitch *notifiableSwitch;
+@property (nonatomic, retain) NSManagedObject *selectedObject;
+#if defined(ENABLE_UNDO_EDITING)
+@property (nonatomic, retain) NSUndoManager *undoManager;
+
+- (void)setUpUndoManager;
+- (void)cleanUpUndoManager;
+#endif
+
 @end
diff -ru -x 'MemoDatesIcon*' -x '*~' -x '*.xcdatamodeld' -x '*.xcodeproj' -x '*.xib' -x build MemoDates+CoreData/Classes/DetailViewController.m MemoDates/Classes/DetailViewController.m
--- MemoDates+CoreData/Classes/DetailViewController.m	2011-01-28 20:15:57.000000000 +0900
+++ MemoDates/Classes/DetailViewController.m	2011-01-28 21:12:55.000000000 +0900
@@ -7,10 +7,23 @@
 //
 
 #import "DetailViewController.h"
-
+#if defined(ENABLE_EDITING_VIEW)
+#import "MemoEditingViewController.h"
+#import "CategoryEditingViewController.h"
+#import "DateEditingViewController.h"
+#endif
 
 @implementation DetailViewController
 
+@synthesize notifiableSwitch;
+@synthesize selectedObject;
+#if defined(ENABLE_UNDO_EDITING)
+@synthesize undoManager;
+#endif
+
+- (void)updateRightBarButtonItemState {
+  self.navigationItem.rightBarButtonItem.enabled = [selectedObject validateForUpdate:NULL];
+}    
 
 #pragma mark -
 #pragma mark Initialization
@@ -30,30 +43,27 @@
 #pragma mark -
 #pragma mark View lifecycle
 
-/*
 - (void)viewDidLoad {
     [super viewDidLoad];
 
     // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
-    // self.navigationItem.rightBarButtonItem = self.editButtonItem;
+    self.navigationItem.rightBarButtonItem = self.editButtonItem;
+    self.tableView.allowsSelectionDuringEditing = YES;  
 }
-*/
 
-/*
 - (void)viewWillAppear:(BOOL)animated {
+  [self.tableView reloadData];
+  [self updateRightBarButtonItemState];
     [super viewWillAppear:animated];
 }
-*/
-/*
 - (void)viewDidAppear:(BOOL)animated {
     [super viewDidAppear:animated];
+    [self becomeFirstResponder];
 }
-*/
-/*
 - (void)viewWillDisappear:(BOOL)animated {
     [super viewWillDisappear:animated];
+    [self resignFirstResponder];
 }
-*/
 /*
 - (void)viewDidDisappear:(BOOL)animated {
     [super viewDidDisappear:animated];
@@ -67,19 +77,41 @@
 }
 */
 
+- (void)setEditing:(BOOL)editing animated:(BOOL)animated {
+  [super setEditing:editing animated:animated];
+  
+  [self.navigationItem setHidesBackButton:editing animated:animated];
+  [self.tableView reloadData];
+  
+  if (editing) {
+#if defined(ENABLE_UNDO_EDITING)
+    [self setUpUndoManager];
+#endif
+  }
+  else {
+#if defined(ENABLE_UNDO_EDITING)
+    [self cleanUpUndoManager];
+#endif
+    NSError *error;
+    if (![selectedObject.managedObjectContext save:&error]) {
+      NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
+      abort();
+    }
+  }
+}
 
 #pragma mark -
 #pragma mark Table view data source
 
 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
     // Return the number of sections.
-    return <#number of sections#>;
+    return 1;
 }
 
 
 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
     // Return the number of rows in the section.
-    return <#number of rows in section#>;
+    return 4;
 }
 
 
@@ -90,14 +122,90 @@
     
     UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
     if (cell == nil) {
-        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
+        cell = [[[UITableViewCell alloc] initWithStyle:/*UITableViewCellStyleDefault*//*UITableViewCellStyleSubtitle*//*UITableViewCellStyleValue1*/UITableViewCellStyleValue2 reuseIdentifier:CellIdentifier] autorelease];
+        cell.editingAccessoryType = UITableViewCellAccessoryDisclosureIndicator;
     }
     
     // Configure the cell...
+  switch (indexPath.row) {
+    case 0:
+      cell.textLabel.text = @"Memo.";
+      cell.detailTextLabel.text = [[selectedObject valueForKey:@"memo"] description];
+      break;
+    case 1:
+      cell.textLabel.text = @"Category";
+      cell.detailTextLabel.text = [[selectedObject valueForKey:@"category"] description];
+      break;
+    case 2:
+      cell.textLabel.text = @"Date";
+      //cell.detailTextLabel.text = [[selectedObject valueForKey:@"date"] description];
+      cell.detailTextLabel.text = [NSDateFormatter localizedStringFromDate:[selectedObject valueForKey:@"date"] dateStyle:NSDateFormatterMediumStyle timeStyle:NSDateFormatterNoStyle];
+      break;
+    default:
+      cell.selectionStyle = UITableViewCellSelectionStyleNone;
+      cell.textLabel.text = @"Notifiable";
+      self.notifiableSwitch.on = [[selectedObject valueForKey:@"notifiable"] boolValue];
+      self.notifiableSwitch.enabled = self.editing;
+      cell.accessoryView = cell.editingAccessoryView = self.notifiableSwitch;
+      break;
+  }
     
     return cell;
 }
 
+- (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath
+{
+  return self.editing ? indexPath : nil;
+}
+- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
+{
+  return UITableViewCellEditingStyleNone;
+}
+- (BOOL)tableView:(UITableView *)tableView shouldIndentWhileEditingRowAtIndexPath:(NSIndexPath *)indexPath
+{
+  return NO;
+}
+
+#if defined(ENABLE_UNDO_EDITING)
+- (void)setUpUndoManager {
+  if (selectedObject.managedObjectContext.undoManager == nil) {
+    NSUndoManager *anUndoManager = [[NSUndoManager alloc] init];
+    [anUndoManager setLevelsOfUndo:4];
+    self.undoManager = anUndoManager;
+    [anUndoManager release];
+    
+    selectedObject.managedObjectContext.undoManager = undoManager;
+  }
+  NSUndoManager *anUndoManager = selectedObject.managedObjectContext.undoManager;
+  
+  NSNotificationCenter *dnc = [NSNotificationCenter defaultCenter];
+  [dnc addObserver:self selector:@selector(undoManagerDidUndo:) name:NSUndoManagerDidUndoChangeNotification object:anUndoManager];
+  [dnc addObserver:self selector:@selector(undoManagerDidRedo:) name:NSUndoManagerDidRedoChangeNotification object:anUndoManager];
+}
+- (void)cleanUpUndoManager {
+  [[NSNotificationCenter defaultCenter] removeObserver:self];
+  
+  if (selectedObject.managedObjectContext.undoManager == undoManager) {
+    selectedObject.managedObjectContext.undoManager = nil;
+    self.undoManager = nil;
+  }        
+}
+- (NSUndoManager *)undoManager {
+  return selectedObject.managedObjectContext.undoManager;
+}
+- (void)undoManagerDidUndo:(NSNotification *)notification {
+  [self.tableView reloadData];
+  [self updateRightBarButtonItemState];
+}
+- (void)undoManagerDidRedo:(NSNotification *)notification {
+  [self.tableView reloadData];
+  [self updateRightBarButtonItemState];
+}
+
+- (BOOL)canBecomeFirstResponder {
+  return YES;
+}
+#endif
 
 /*
 // Override to support conditional editing of the table view.
@@ -151,6 +259,47 @@
     [self.navigationController pushViewController:detailViewController animated:YES];
     [detailViewController release];
     */
+#if defined(ENABLE_EDITING_VIEW)
+  switch (indexPath.row) {
+    case 0: {
+        MemoEditingViewController *controller = [[MemoEditingViewController alloc] initWithNibName:@"MemoEditingViewController" bundle:nil];
+        controller.editedObject = selectedObject;
+        [self.navigationController pushViewController:controller animated:YES];
+        [controller release];
+      }
+      break;
+    case 1: {
+        CategoryEditingViewController *controller = [[CategoryEditingViewController alloc] initWithNibName:@"CategoryEditingViewController" bundle:nil];
+        controller.editedObject = selectedObject;
+        [self.navigationController pushViewController:controller animated:YES];
+        [controller release];
+      } 
+      break;
+    case 2: {
+        DateEditingViewController *controller = [[DateEditingViewController alloc] initWithNibName:@"DateEditingViewController" bundle:nil];
+        controller.editedObject = selectedObject;
+        [self.navigationController pushViewController:controller animated:YES];
+        [controller release];
+      } 
+      break;
+  }
+#endif
+}
+
+- (IBAction)notifiableSwitchValueChanged:(UISwitch *)sender
+{
+#if defined(ENABLE_UNDO_EDITING)
+  [undoManager setActionName:[NSString stringWithFormat:@"Notifiable"]];
+#endif
+  [selectedObject setValue:[NSNumber numberWithBool:sender.on] forKey:@"notifiable"];
+}
+
+- (UISwitch *)notifiableSwitch {
+  if (notifiableSwitch == nil) {
+    notifiableSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
+    [notifiableSwitch addTarget:self action:@selector(notifiableSwitchValueChanged:) forControlEvents:UIControlEventValueChanged];
+  }
+  return notifiableSwitch;
 }
 
 
@@ -167,10 +316,16 @@
 - (void)viewDidUnload {
     // Relinquish ownership of anything that can be recreated in viewDidLoad or on demand.
     // For example: self.myOutlet = nil;
+  self.notifiableSwitch = nil;
 }
 
 
 - (void)dealloc {
+#if defined(ENABLE_UNDO_EDITING)
+  [undoManager release];
+#endif
+  [notifiableSwitch release];
+  [selectedObject release];
     [super dealloc];
 }
 
diff -ru -x 'MemoDatesIcon*' -x '*~' -x '*.xcdatamodeld' -x '*.xcodeproj' -x '*.xib' -x build MemoDates+CoreData/Classes/EditingViewController.h MemoDates/Classes/EditingViewController.h
--- MemoDates+CoreData/Classes/EditingViewController.h	2011-01-28 20:17:19.000000000 +0900
+++ MemoDates/Classes/EditingViewController.h	2011-01-28 21:59:11.000000000 +0900
@@ -10,7 +10,12 @@
 
 
 @interface EditingViewController : UIViewController {
-
+  NSManagedObject *editedObject;
 }
 
+@property (nonatomic, retain) NSManagedObject *editedObject;
+
+- (IBAction)cancel:(id)sender;
+- (IBAction)save:(id)sender;
+
 @end
diff -ru -x 'MemoDatesIcon*' -x '*~' -x '*.xcdatamodeld' -x '*.xcodeproj' -x '*.xib' -x build MemoDates+CoreData/Classes/EditingViewController.m MemoDates/Classes/EditingViewController.m
--- MemoDates+CoreData/Classes/EditingViewController.m	2011-01-28 20:17:19.000000000 +0900
+++ MemoDates/Classes/EditingViewController.m	2011-01-28 21:57:49.000000000 +0900
@@ -11,6 +11,8 @@
 
 @implementation EditingViewController
 
+@synthesize editedObject;
+
 // The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
 /*
 - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
@@ -22,12 +24,18 @@
 }
 */
 
-/*
 // Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
 - (void)viewDidLoad {
     [super viewDidLoad];
+
+  UIBarButtonItem *saveButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSave target:self action:@selector(save:)];
+  self.navigationItem.rightBarButtonItem = saveButton;
+  [saveButton release];
+
+  UIBarButtonItem *cancelButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(cancel:)];
+  self.navigationItem.leftBarButtonItem = cancelButton;
+  [cancelButton release];
 }
-*/
 
 /*
 // Override to allow orientations other than the default portrait orientation.
@@ -50,8 +58,15 @@
     // e.g. self.myOutlet = nil;
 }
 
+- (IBAction)cancel:(id)sender {
+  [self.navigationController popViewControllerAnimated:YES];
+}
+- (IBAction)save:(id)sender {
+  [self.navigationController popViewControllerAnimated:YES];
+}
 
 - (void)dealloc {
+    [editedObject release];
     [super dealloc];
 }
 
diff -ru -x 'MemoDatesIcon*' -x '*~' -x '*.xcdatamodeld' -x '*.xcodeproj' -x '*.xib' -x build MemoDates+CoreData/Classes/MemoDatesAppDelegate.m MemoDates/Classes/MemoDatesAppDelegate.m
--- MemoDates+CoreData/Classes/MemoDatesAppDelegate.m	2011-01-26 22:14:43.000000000 +0900
+++ MemoDates/Classes/MemoDatesAppDelegate.m	2011-02-01 19:15:38.000000000 +0900
@@ -175,6 +175,40 @@
         abort();
     }    
     
+#if !defined(ENABLE_DETAIL_VIEW)
+  NSEntityDescription *entity = [NSEntityDescription entityForName:@"MemoDate" inManagedObjectContext:self.managedObjectContext];
+  struct {
+    NSString *memo, *category;
+    NSString *date;
+    BOOL notifiable;
+  } fake_data_set[] = {
+    { @"父の誕生日", nil, @"1935/06/11", YES },
+    { @"母の誕生日", nil, @"1939/10/16", NO },
+    { @"姉の誕生日", nil, @"1961/01/01", YES },
+    { @"兄の誕生日", nil, @"1965/01/01", YES },
+    { @"自分の誕生日", nil, @"1970/05/20", YES },
+    { @"妻の誕生日", nil, @"1971/01/01", YES },
+    { @"長男の誕生日", nil, @"2003/01/01", YES },
+    { @"長女の誕生日", nil, @"2007/01/01", YES },
+    { @"次女の誕生日", nil, @"2009/01/01", YES },
+    { @"会社の創立記念日", @"Office", @"2011/01/13", YES },
+  };
+  NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
+  NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
+  [dateFormatter setCalendar:calendar];
+  [calendar release];
+  [dateFormatter setDateFormat:@"yyyy/MM/DD"];
+  size_t i;
+  for (i=0; i<sizeof(fake_data_set)/sizeof(fake_data_set[0]); i++) {
+    NSManagedObject *newManagedObject = [NSEntityDescription insertNewObjectForEntityForName:[entity name] inManagedObjectContext:self.managedObjectContext];
+    [newManagedObject setValue:fake_data_set[i].memo forKey:@"memo"];
+    if (fake_data_set[i].category) [newManagedObject setValue:fake_data_set[i].category forKey:@"category"];
+    [newManagedObject setValue:[dateFormatter dateFromString:fake_data_set[i].date] forKey:@"date"];
+    [newManagedObject setValue:[NSNumber numberWithBool:fake_data_set[i].notifiable] forKey:@"notifiable"];
+  }
+  [dateFormatter release];
+  [self.managedObjectContext save:NULL];
+#endif
     return persistentStoreCoordinator_;
 }
 
diff -ru -x 'MemoDatesIcon*' -x '*~' -x '*.xcdatamodeld' -x '*.xcodeproj' -x '*.xib' -x build MemoDates+CoreData/Classes/MemoEditingViewController.h MemoDates/Classes/MemoEditingViewController.h
--- MemoDates+CoreData/Classes/MemoEditingViewController.h	2011-01-28 20:17:42.000000000 +0900
+++ MemoDates/Classes/MemoEditingViewController.h	2011-01-28 20:48:29.000000000 +0900
@@ -7,10 +7,10 @@
 //
 
 #import <UIKit/UIKit.h>
+#import "EditingViewController.h"
 
-
-@interface MemoEditingViewController : UIViewController {
-
+@interface MemoEditingViewController : EditingViewController {
+  IBOutlet UITextField *textField;
 }
 
 @end
diff -ru -x 'MemoDatesIcon*' -x '*~' -x '*.xcdatamodeld' -x '*.xcodeproj' -x '*.xib' -x build MemoDates+CoreData/Classes/MemoEditingViewController.m MemoDates/Classes/MemoEditingViewController.m
--- MemoDates+CoreData/Classes/MemoEditingViewController.m	2011-01-28 20:17:42.000000000 +0900
+++ MemoDates/Classes/MemoEditingViewController.m	2011-01-28 22:01:58.000000000 +0900
@@ -22,12 +22,17 @@
 }
 */
 
-/*
 // Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
 - (void)viewDidLoad {
     [super viewDidLoad];
+    self.title = @"Memo.";
+}
+
+- (void)viewWillAppear:(BOOL)animated {
+  [super viewWillAppear:animated];
+  textField.text = [editedObject valueForKey:@"memo"];
+  [textField becomeFirstResponder];
 }
-*/
 
 /*
 // Override to allow orientations other than the default portrait orientation.
@@ -50,6 +55,17 @@
     // e.g. self.myOutlet = nil;
 }
 
+- (IBAction)cancel:(id)sender {
+  [super cancel:sender];
+}
+- (IBAction)save:(id)sender {
+#if defined(ENABLE_UNDO_EDITING)
+  NSUndoManager *undoManager = [[editedObject managedObjectContext] undoManager];
+  [undoManager setActionName:[NSString stringWithFormat:@"%@", self.title]];
+#endif  
+  [editedObject setValue:textField.text forKey:@"memo"];
+  [super save:sender];
+}
 
 - (void)dealloc {
     [super dealloc];
diff -ru -x 'MemoDatesIcon*' -x '*~' -x '*.xcdatamodeld' -x '*.xcodeproj' -x '*.xib' -x build MemoDates+CoreData/Classes/RootViewController.h MemoDates/Classes/RootViewController.h
--- MemoDates+CoreData/Classes/RootViewController.h	2011-01-26 22:14:43.000000000 +0900
+++ MemoDates/Classes/RootViewController.h	2011-01-28 21:16:03.000000000 +0900
@@ -8,14 +8,26 @@
 
 #import <UIKit/UIKit.h>
 #import <CoreData/CoreData.h>
+#if defined(ENABLE_ADD_VIEW)
+#import "AddViewController.h"
+#endif
 
-@interface RootViewController : UITableViewController <NSFetchedResultsControllerDelegate> {
-
+@interface RootViewController : UITableViewController <NSFetchedResultsControllerDelegate
+#if defined(ENABLE_ADD_VIEW)
+, AddViewControllerDelegate
+#endif
+> {
 @private
     NSFetchedResultsController *fetchedResultsController_;
     NSManagedObjectContext *managedObjectContext_;
+#if defined(ENABLE_ADD_VIEW)
+    NSManagedObjectContext *addingManagedObjectContext_;
+#endif
 }
 
+#if defined(ENABLE_ADD_VIEW)
+@property (nonatomic, retain) NSManagedObjectContext *addingManagedObjectContext;
+#endif
 @property (nonatomic, retain) NSManagedObjectContext *managedObjectContext;
 @property (nonatomic, retain) NSFetchedResultsController *fetchedResultsController;
 
diff -ru -x 'MemoDatesIcon*' -x '*~' -x '*.xcdatamodeld' -x '*.xcodeproj' -x '*.xib' -x build MemoDates+CoreData/Classes/RootViewController.m MemoDates/Classes/RootViewController.m
--- MemoDates+CoreData/Classes/RootViewController.m	2011-01-26 22:14:43.000000000 +0900
+++ MemoDates/Classes/RootViewController.m	2011-01-28 22:15:26.000000000 +0900
@@ -7,7 +7,12 @@
 //
 
 #import "RootViewController.h"
-
+#if defined(ENABLE_DETAIL_VIEW)
+#import "DetailViewController.h"
+#endif
+#if defined(ENABLE_ADD_VIEW)
+#import "AddViewController.h"
+#endif
 
 @interface RootViewController ()
 - (void)configureCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath;
@@ -17,13 +22,16 @@
 @implementation RootViewController
 
 @synthesize fetchedResultsController=fetchedResultsController_, managedObjectContext=managedObjectContext_;
-
+#if defined(ENABLE_ADD_VIEW)
+@synthesize addingManagedObjectContext=addingManagedObjectContext_;
+#endif
 
 #pragma mark -
 #pragma mark View lifecycle
 
 - (void)viewDidLoad {
     [super viewDidLoad];
+    self.title = @"MemoDate List";
 
     // Set up the edit and add buttons.
     self.navigationItem.leftBarButtonItem = self.editButtonItem;
@@ -36,6 +44,7 @@
 
 // Implement viewWillAppear: to do additional setup before the view is presented.
 - (void)viewWillAppear:(BOOL)animated {
+    [self.tableView reloadData];
     [super viewWillAppear:animated];
 }
 
@@ -68,7 +77,12 @@
 - (void)configureCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath {
     
     NSManagedObject *managedObject = [self.fetchedResultsController objectAtIndexPath:indexPath];
-    cell.textLabel.text = [[managedObject valueForKey:@"timeStamp"] description];
+    cell.textLabel.text = [[managedObject valueForKey:@"memo"] description];
+    //cell.detailTextLabel.text = [[managedObject valueForKey:@"date"] description];
+    //cell.detailTextLabel.text = [NSDateFormatter localizedStringFromDate:[managedObject valueForKey:@"date"] dateStyle:NSDateFormatterMediumStyle timeStyle:NSDateFormatterNoStyle];
+    //cell.accessoryType = [[managedObject valueForKey:@"notifiable"] boolValue] ? UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone;
+    cell.detailTextLabel.text = [NSString stringWithFormat:@"%@ %@", [NSDateFormatter localizedStringFromDate:[managedObject valueForKey:@"date"] dateStyle:NSDateFormatterMediumStyle timeStyle:NSDateFormatterNoStyle],
+                                 [[managedObject valueForKey:@"notifiable"] boolValue] ? @"☑" : @"☒" ];
 }
 
 
@@ -76,15 +90,18 @@
 #pragma mark Add a new object
 
 - (void)insertNewObject {
-    
+#if !defined(ENABLE_ADD_VIEW)
     // Create a new instance of the entity managed by the fetched results controller.
     NSManagedObjectContext *context = [self.fetchedResultsController managedObjectContext];
     NSEntityDescription *entity = [[self.fetchedResultsController fetchRequest] entity];
     NSManagedObject *newManagedObject = [NSEntityDescription insertNewObjectForEntityForName:[entity name] inManagedObjectContext:context];
     
     // If appropriate, configure the new managed object.
-    [newManagedObject setValue:[NSDate date] forKey:@"timeStamp"];
-    
+    [newManagedObject setValue:@"Hoge" forKey:@"memo"];
+    [newManagedObject setValue:@"Piyo" forKey:@"category"];
+    [newManagedObject setValue:[NSDate date] forKey:@"date"];
+    [newManagedObject setValue:[NSNumber numberWithBool:YES] forKey:@"notifiable"];
+
     // Save the context.
     NSError *error = nil;
     if (![context save:&error]) {
@@ -96,7 +113,50 @@
         NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
         abort();
     }
+#else
+  NSManagedObjectContext *context = [[NSManagedObjectContext alloc] init];
+  [context setPersistentStoreCoordinator:[[self.fetchedResultsController managedObjectContext] persistentStoreCoordinator]];
+  NSEntityDescription *entity = [[self.fetchedResultsController fetchRequest] entity];
+  
+  AddViewController *addViewController = [[AddViewController alloc] initWithStyle:UITableViewStyleGrouped/*UITableViewStylePlain*/];
+  addViewController.delegate = self;
+  addViewController.selectedObject = [NSEntityDescription insertNewObjectForEntityForName:[entity name] inManagedObjectContext:context];
+  [addViewController.selectedObject setValue:[NSDate date] forKey:@"date"];
+  self.addingManagedObjectContext = context;
+  [context release];
+  
+  UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:addViewController];
+  [self.navigationController presentModalViewController:navController animated:YES];
+  
+  [addViewController release];
+  [navController release];
+#endif
+}
+
+#if defined(ENABLE_ADD_VIEW)
+- (void)addViewController:(AddViewController *)controller didFinishWithSave:(BOOL)save {
+  
+  if (save) {
+    NSNotificationCenter *dnc = [NSNotificationCenter defaultCenter];
+    [dnc addObserver:self selector:@selector(addControllerContextDidSave:) name:NSManagedObjectContextDidSaveNotification object:self.addingManagedObjectContext];
+    
+    NSError *error;
+    if (![self.addingManagedObjectContext save:&error]) {
+      NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
+      abort();
+    }
+    [dnc removeObserver:self name:NSManagedObjectContextDidSaveNotification object:self.addingManagedObjectContext];
+  }
+  self.addingManagedObjectContext = nil;
+  
+  [self dismissModalViewControllerAnimated:YES];
+}
+- (void)addControllerContextDidSave:(NSNotification*)saveNotification {
+  
+  NSManagedObjectContext *context = [self.fetchedResultsController managedObjectContext];
+  [context mergeChangesFromContextDidSaveNotification:saveNotification];
 }
+#endif
 
 
 - (void)setEditing:(BOOL)editing animated:(BOOL)animated {
@@ -128,7 +188,7 @@
     
     UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
     if (cell == nil) {
-        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
+      cell = [[[UITableViewCell alloc] initWithStyle:/*UITableViewCellStyleDefault*/UITableViewCellStyleSubtitle/*UITableViewCellStyleValue1*//*UITableViewCellStyleValue2*/ reuseIdentifier:CellIdentifier] autorelease];
     }
     
     // Configure the cell.
@@ -138,6 +198,9 @@
 }
 
 
+- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
+  return [[self.fetchedResultsController.sections objectAtIndex:section] name];
+}
 
 /*
 // Override to support conditional editing of the table view.
@@ -182,14 +245,15 @@
 
 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
     // Navigation logic may go here -- for example, create and push another view controller.
-    /*
-     <#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil];
+#if defined(ENABLE_DETAIL_VIEW)
+     DetailViewController *detailViewController = [[DetailViewController alloc] initWithStyle:UITableViewStyleGrouped];
      NSManagedObject *selectedObject = [[self fetchedResultsController] objectAtIndexPath:indexPath];
+     detailViewController.selectedObject = selectedObject;
      // ...
      // Pass the selected object to the new view controller.
      [self.navigationController pushViewController:detailViewController animated:YES];
      [detailViewController release];
-     */
+#endif
 }
 
 
@@ -208,27 +272,29 @@
     // Create the fetch request for the entity.
     NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
     // Edit the entity name as appropriate.
-    NSEntityDescription *entity = [NSEntityDescription entityForName:@"Event" inManagedObjectContext:self.managedObjectContext];
+    NSEntityDescription *entity = [NSEntityDescription entityForName:@"MemoDate" inManagedObjectContext:self.managedObjectContext];
     [fetchRequest setEntity:entity];
     
     // Set the batch size to a suitable number.
     [fetchRequest setFetchBatchSize:20];
     
     // Edit the sort key as appropriate.
-    NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"timeStamp" ascending:NO];
-    NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor, nil];
+    NSSortDescriptor *categorySortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"category" ascending:YES];
+    NSSortDescriptor *dateSortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"date" ascending:NO];
+    NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:categorySortDescriptor, dateSortDescriptor, nil];
     
     [fetchRequest setSortDescriptors:sortDescriptors];
     
     // Edit the section name key path and cache name if appropriate.
     // nil for section name key path means "no sections".
-    NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:self.managedObjectContext sectionNameKeyPath:nil cacheName:@"Root"];
+    NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:self.managedObjectContext sectionNameKeyPath:@"category" cacheName:@"Root"];
     aFetchedResultsController.delegate = self;
     self.fetchedResultsController = aFetchedResultsController;
     
     [aFetchedResultsController release];
     [fetchRequest release];
-    [sortDescriptor release];
+    [categorySortDescriptor release];
+    [dateSortDescriptor release];
     [sortDescriptors release];
     
     NSError *error = nil;
@@ -327,12 +393,16 @@
 - (void)viewDidUnload {
     // Relinquish ownership of anything that can be recreated in viewDidLoad or on demand.
     // For example: self.myOutlet = nil;
+  self.fetchedResultsController = nil;
 }
 
 
 - (void)dealloc {
     [fetchedResultsController_ release];
     [managedObjectContext_ release];
+#if defined(ENABLE_ADD_VIEW)
+    [addingManagedObjectContext_ release];
+#endif
     [super dealloc];
 }
 
diff -ru -x 'MemoDatesIcon*' -x '*~' -x '*.xcdatamodeld' -x '*.xcodeproj' -x '*.xib' -x build MemoDates+CoreData/MemoDates-Info.plist MemoDates/MemoDates-Info.plist
--- MemoDates+CoreData/MemoDates-Info.plist	2011-01-26 22:14:43.000000000 +0900
+++ MemoDates/MemoDates-Info.plist	2011-01-13 23:05:08.000000000 +0900
@@ -9,9 +9,9 @@
 	<key>CFBundleExecutable</key>
 	<string>${EXECUTABLE_NAME}</string>
 	<key>CFBundleIconFile</key>
-	<string></string>
+	<string>MemoDatesIcon</string>
 	<key>CFBundleIdentifier</key>
-	<string>com.yourcompany.${PRODUCT_NAME:rfc1034identifier}</string>
+	<string>com.mac.taiji-yamada.${PRODUCT_NAME:rfc1034identifier}</string>
 	<key>CFBundleInfoDictionaryVersion</key>
 	<string>6.0</string>
 	<key>CFBundleName</key>
@@ -26,5 +26,7 @@
 	<true/>
 	<key>NSMainNibFile</key>
 	<string>MainWindow</string>
+	<key>UIApplicationExitsOnSuspend</key>
+	<true/>
 </dict>
 </plist>
