Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Hack together support for editing dates.

  • Loading branch information...
commit b6ca21ecacddabbc5c0624c6fe1325fa7f9726c9 1 parent 7dae5dd
@mikeabdullah authored
View
25 DCTDatePickerViewController.h
@@ -0,0 +1,25 @@
+//
+// DCTDatePickerViewController.h
+// Climb Tracker
+//
+// Created by Mike Abdullah on 08/12/2011.
+// Copyright (c) 2011 Karelia Software. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+
+@interface DCTDatePickerViewController : UIViewController <UITableViewDataSource, UITableViewDelegate>
+{
+ IBOutlet UITableView *tableView;
+ IBOutlet UIDatePicker *datePicker;
+
+@private
+ NSDateFormatter *_formatter;
+}
+
+@property(nonatomic, copy) NSDate *date;
+
+- (IBAction)dateChanged:(id)sender;
+
+@end
View
114 DCTDatePickerViewController.m
@@ -0,0 +1,114 @@
+//
+// DCTDatePickerViewController.m
+// Climb Tracker
+//
+// Created by Mike Abdullah on 08/12/2011.
+// Copyright (c) 2011 Karelia Software. All rights reserved.
+//
+
+#import "DCTDatePickerViewController.h"
+
+
+@implementation DCTDatePickerViewController
+
+- (NSDate *)date;
+{
+ return [datePicker date];
+}
+- (void)setDate:(NSDate *)date
+{
+ [self view]; // make sure it's loaded
+ [datePicker setDate:date];
+}
+
+#pragma mark Lifecycle
+
+- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
+{
+ self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
+ if (self) {
+ // Custom initialization
+ }
+ return self;
+}
+
+- (void)didReceiveMemoryWarning
+{
+ // Releases the view if it doesn't have a superview.
+ [super didReceiveMemoryWarning];
+
+ // Release any cached data, images, etc that aren't in use.
+}
+
+- (void)dealloc
+{
+ [_formatter release];
+ [super dealloc];
+}
+
+#pragma mark - View lifecycle
+
+- (void)viewDidLoad
+{
+ [super viewDidLoad];
+ // Do any additional setup after loading the view from its nib.
+}
+
+- (void)viewDidUnload
+{
+ [super viewDidUnload];
+ // Release any retained subviews of the main view.
+ // e.g. self.myOutlet = nil;
+}
+
+- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
+{
+ // Return YES for supported orientations
+ return (interfaceOrientation == UIInterfaceOrientationPortrait);
+}
+
+- (void)viewWillAppear:(BOOL)animated
+{
+ [self dateChanged:nil]; // make sure table & picker are up-to-date
+}
+
+#pragma mark - Table View Data Source
+
+- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
+{
+ return 1;
+}
+
+- (UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
+{
+ static NSString *fallsCellIdentifier = @"Cell";
+
+ UITableViewCell *cell = [aTableView dequeueReusableCellWithIdentifier:fallsCellIdentifier];
+ if (cell == nil)
+ {
+ cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:fallsCellIdentifier] autorelease];
+ }
+
+ cell.textLabel.text = NSLocalizedString(@"Date", "cell title");
+
+ if (!_formatter)
+ {
+ _formatter = [[NSDateFormatter alloc] init];
+ _formatter.dateStyle = NSDateFormatterLongStyle;
+ _formatter.timeStyle = NSDateFormatterShortStyle;
+ }
+ cell.detailTextLabel.text = [_formatter stringFromDate:self.date];
+
+
+ return cell;
+}
+
+#pragma mark - Picker
+
+- (void)dateChanged:(id)sender
+{
+ [tableView reloadData];
+ [tableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:NO scrollPosition:UITableViewScrollPositionMiddle];
+}
+
+@end
View
303 DCTDatePickerViewController.xib
@@ -0,0 +1,303 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="8.00">
+ <data>
+ <int key="IBDocument.SystemTarget">1280</int>
+ <string key="IBDocument.SystemVersion">11C73</string>
+ <string key="IBDocument.InterfaceBuilderVersion">1938</string>
+ <string key="IBDocument.AppKitVersion">1138.23</string>
+ <string key="IBDocument.HIToolboxVersion">567.00</string>
+ <object class="NSMutableDictionary" key="IBDocument.PluginVersions">
+ <string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ <string key="NS.object.0">933</string>
+ </object>
+ <array key="IBDocument.IntegratedClassDependencies">
+ <string>IBUITableView</string>
+ <string>IBUIView</string>
+ <string>IBUIDatePicker</string>
+ <string>IBProxyObject</string>
+ </array>
+ <array key="IBDocument.PluginDependencies">
+ <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ </array>
+ <object class="NSMutableDictionary" key="IBDocument.Metadata">
+ <string key="NS.key.0">PluginDependencyRecalculationVersion</string>
+ <integer value="1" key="NS.object.0"/>
+ </object>
+ <array class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
+ <object class="IBProxyObject" id="372490531">
+ <string key="IBProxiedObjectIdentifier">IBFilesOwner</string>
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
+ </object>
+ <object class="IBProxyObject" id="975951072">
+ <string key="IBProxiedObjectIdentifier">IBFirstResponder</string>
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
+ </object>
+ <object class="IBUIView" id="191373211">
+ <reference key="NSNextResponder"/>
+ <int key="NSvFlags">274</int>
+ <array class="NSMutableArray" key="NSSubviews">
+ <object class="IBUITableView" id="110642538">
+ <reference key="NSNextResponder" ref="191373211"/>
+ <int key="NSvFlags">274</int>
+ <string key="NSFrameSize">{320, 200}</string>
+ <reference key="NSSuperview" ref="191373211"/>
+ <reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="1045622061"/>
+ <string key="NSReuseIdentifierKey">_NS:418</string>
+ <object class="NSColor" key="IBUIBackgroundColor">
+ <int key="NSColorSpace">10</int>
+ <object class="NSImage" key="NSImage">
+ <int key="NSImageFlags">549453824</int>
+ <string key="NSSize">{512, 1}</string>
+ <array class="NSMutableArray" key="NSReps">
+ <array>
+ <integer value="0"/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NT/xczU/8XM1P/FzNT/xczS/8vS2P/L0tj/xczU/8XM1P/FzNT/
+xczU/8XM0v/L0tj/y9LY/8XM1P/FzNT/xczU/8XM1P/FzNL/y9LY/8vS2P/FzNT/xczU/8XM1P/FzNT/
+xczS/8vS2P/L0tj/xczU/8XM1P/FzNT/xczU/8XM0v/L0tj/y9LY/8XM1P/FzNT/xczU/8XM1P/FzNL/
+y9LY/8vS2P/FzNT/xczU/8XM1P/FzNT/xczS/8vS2P/L0tj/xczU/8XM1P/FzNT/xczU/8XM0v/L0tj/
+y9LY/8XM1P/FzNT/xczU/8XM1P/FzNL/y9LY/8vS2P/FzNT/xczU/8XM1P/FzNT/xczS/8vS2P/L0tj/
+xczU/8XM1P/FzNT/xczU/8XM0v/L0tj/y9LY/8XM1P/FzNT/xczU/8XM1P/FzNL/y9LY/8vS2P/FzNT/
+xczU/8XM1P/FzNT/xczS/8vS2P/L0tj/xczU/8XM1P/FzNT/xczU/8XM0v/L0tj/y9LY/8XM1P/FzNT/
+xczU/8XM1P/FzNL/y9LY/8vS2P/FzNT/xczU/8XM1P/FzNT/xczS/8vS2P/L0tj/xczU/8XM1P/FzNT/
+xczU/8XM0v/L0tj/y9LY/8XM1P/FzNT/xczU/8XM1P/FzNL/y9LY/8vS2P/FzNT/xczU/8XM1P/FzNT/
+xczS/8vS2P/L0tj/xczU/wANAQAAAwAAAAECAAAAAQEAAwAAAAEAAQAAAQIAAwAAAAQAAAiqAQMAAwAA
+AAEAAQAAAQYAAwAAAAEAAgAAAREABAAAAAEAAAAIARIAAwAAAAEAAQAAARUAAwAAAAEABAAAARYAAwAA
+AAEAAQAAARcABAAAAAEAAAgAARwAAwAAAAEAAQAAAVIAAwAAAAEAAQAAAVMAAwAAAAQAAAiyAAAAAAAI
+AAgACAAIAAEAAQABAAE</bytes>
+ </object>
+ </object>
+ </array>
+ </array>
+ <object class="NSColor" key="NSColor">
+ <int key="NSColorSpace">3</int>
+ <bytes key="NSWhite">MCAwAA</bytes>
+ </object>
+ </object>
+ <string key="IBUIColorCocoaTouchKeyPath">groupTableViewBackgroundColor</string>
+ </object>
+ <bool key="IBUIClipsSubviews">YES</bool>
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
+ <bool key="IBUIBounces">NO</bool>
+ <bool key="IBUIAlwaysBounceVertical">YES</bool>
+ <int key="IBUIStyle">1</int>
+ <int key="IBUISeparatorStyle">2</int>
+ <int key="IBUISectionIndexMinimumDisplayRowCount">0</int>
+ <bool key="IBUIShowsSelectionImmediatelyOnTouchBegin">YES</bool>
+ <float key="IBUIRowHeight">44</float>
+ <float key="IBUISectionHeaderHeight">10</float>
+ <float key="IBUISectionFooterHeight">10</float>
+ </object>
+ <object class="IBUIDatePicker" id="1045622061">
+ <reference key="NSNextResponder" ref="191373211"/>
+ <int key="NSvFlags">266</int>
+ <string key="NSFrame">{{0, 200}, {320, 216}}</string>
+ <reference key="NSSuperview" ref="191373211"/>
+ <reference key="NSWindow"/>
+ <reference key="NSNextKeyView"/>
+ <string key="NSReuseIdentifierKey">_NS:578</string>
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
+ <int key="IBUIContentHorizontalAlignment">0</int>
+ <int key="IBUIContentVerticalAlignment">0</int>
+ <object class="NSLocale" key="IBUILocale">
+ <string key="NS.identifier">en_US</string>
+ </object>
+ <object class="NSTimeZone" key="IBUITimeZone">
+ <string key="NS.name">America/Los_Angeles</string>
+ <object class="NSMutableData" key="NS.data">
+ <bytes key="NS.bytes">VFppZgAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAAAAAC5AAAABAAAABCepkign7sVkKCGKqChmveQ
+y4kaoNIj9HDSYSYQ1v50INiArZDa/tGg28CQENzes6DdqayQ3r6VoN+JjpDgnneg4WlwkOJ+WaDjSVKQ
+5F47oOUpNJDmR1gg5xJREOgnOiDo8jMQ6gccIOrSFRDr5v4g7LH3EO3G4CDukdkQ76/8oPBxuxDxj96g
+8n/BkPNvwKD0X6OQ9U+ioPY/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UERUAFBTVABQV1QAUFBUAAAAAAEAAAABA</bytes>
+ </object>
+ </object>
+ <object class="NSDate" key="IBUIDate">
+ <double key="NS.time">344704425.58529598</double>
+ </object>
+ <int key="IBUIMinuteInterval">1</int>
+ </object>
+ </array>
+ <string key="NSFrame">{{0, 64}, {320, 416}}</string>
+ <reference key="NSSuperview"/>
+ <reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="110642538"/>
+ <object class="NSColor" key="IBUIBackgroundColor">
+ <int key="NSColorSpace">3</int>
+ <bytes key="NSWhite">MQA</bytes>
+ <object class="NSColorSpace" key="NSCustomColorSpace">
+ <int key="NSID">2</int>
+ </object>
+ </object>
+ <object class="IBUISimulatedStatusBarMetrics" key="IBUISimulatedStatusBarMetrics"/>
+ <object class="IBUISimulatedNavigationBarMetrics" key="IBUISimulatedTopBarMetrics">
+ <bool key="IBUIPrompted">NO</bool>
+ </object>
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
+ </object>
+ </array>
+ <object class="IBObjectContainer" key="IBDocument.Objects">
+ <array class="NSMutableArray" key="connectionRecords">
+ <object class="IBConnectionRecord">
+ <object class="IBCocoaTouchOutletConnection" key="connection">
+ <string key="label">view</string>
+ <reference key="source" ref="372490531"/>
+ <reference key="destination" ref="191373211"/>
+ </object>
+ <int key="connectionID">3</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBCocoaTouchOutletConnection" key="connection">
+ <string key="label">datePicker</string>
+ <reference key="source" ref="372490531"/>
+ <reference key="destination" ref="1045622061"/>
+ </object>
+ <int key="connectionID">6</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBCocoaTouchOutletConnection" key="connection">
+ <string key="label">tableView</string>
+ <reference key="source" ref="372490531"/>
+ <reference key="destination" ref="110642538"/>
+ </object>
+ <int key="connectionID">9</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBCocoaTouchOutletConnection" key="connection">
+ <string key="label">dataSource</string>
+ <reference key="source" ref="110642538"/>
+ <reference key="destination" ref="372490531"/>
+ </object>
+ <int key="connectionID">7</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBCocoaTouchOutletConnection" key="connection">
+ <string key="label">delegate</string>
+ <reference key="source" ref="110642538"/>
+ <reference key="destination" ref="372490531"/>
+ </object>
+ <int key="connectionID">8</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBCocoaTouchEventConnection" key="connection">
+ <string key="label">dateChanged:</string>
+ <reference key="source" ref="1045622061"/>
+ <reference key="destination" ref="372490531"/>
+ <int key="IBEventType">13</int>
+ </object>
+ <int key="connectionID">10</int>
+ </object>
+ </array>
+ <object class="IBMutableOrderedSet" key="objectRecords">
+ <array key="orderedObjects">
+ <object class="IBObjectRecord">
+ <int key="objectID">0</int>
+ <array key="object" id="0"/>
+ <reference key="children" ref="1000"/>
+ <nil key="parent"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">1</int>
+ <reference key="object" ref="191373211"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="110642538"/>
+ <reference ref="1045622061"/>
+ </array>
+ <reference key="parent" ref="0"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">-1</int>
+ <reference key="object" ref="372490531"/>
+ <reference key="parent" ref="0"/>
+ <string key="objectName">File's Owner</string>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">-2</int>
+ <reference key="object" ref="975951072"/>
+ <reference key="parent" ref="0"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">4</int>
+ <reference key="object" ref="110642538"/>
+ <reference key="parent" ref="191373211"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">5</int>
+ <reference key="object" ref="1045622061"/>
+ <reference key="parent" ref="191373211"/>
+ </object>
+ </array>
+ </object>
+ <dictionary class="NSMutableDictionary" key="flattenedProperties">
+ <string key="-1.CustomClassName">DCTDatePickerViewController</string>
+ <string key="-1.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ <string key="-2.CustomClassName">UIResponder</string>
+ <string key="-2.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ <string key="1.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ <string key="4.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ <string key="5.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ </dictionary>
+ <dictionary class="NSMutableDictionary" key="unlocalizedProperties"/>
+ <nil key="activeLocalization"/>
+ <dictionary class="NSMutableDictionary" key="localizations"/>
+ <nil key="sourceID"/>
+ <int key="maxID">10</int>
+ </object>
+ <object class="IBClassDescriber" key="IBDocument.Classes">
+ <array class="NSMutableArray" key="referencedPartialClassDescriptions">
+ <object class="IBPartialClassDescription">
+ <string key="className">DCTDatePickerViewController</string>
+ <string key="superclassName">UIViewController</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBProjectSource</string>
+ <string key="minorKey">./Classes/DCTDatePickerViewController.h</string>
+ </object>
+ </object>
+ </array>
+ </object>
+ <int key="IBDocument.localizationMode">0</int>
+ <string key="IBDocument.TargetRuntimeIdentifier">IBCocoaTouchFramework</string>
+ <bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
+ <int key="IBDocument.defaultPropertyAccessControl">3</int>
+ <string key="IBCocoaTouchPluginVersion">933</string>
+ </data>
+</archive>
View
1  DCTManagedObjectViewController.h
@@ -13,6 +13,7 @@
{
NSArray *relationships;
NSArray *attributes;
+ NSUInteger _editingDateRow;
}
@property (nonatomic, retain) NSManagedObject *managedObject;
View
68 DCTManagedObjectViewController.m
@@ -10,9 +10,12 @@
NSInteger const DCTManagedObjectViewControllerRelationshipSection = 2;
#import "DCTManagedObjectViewController.h"
+
+#import "DCTDatePickerViewController.h"
#import "DCTManagedObjectRelationshipsViewController.h"
#import "NSManagedObject+DCTNiceDescription.h"
+
@interface DCTManagedObjectViewController ()
@end
@@ -134,8 +137,10 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
cell.textLabel.text = attributeName;
cell.detailTextLabel.text = [[managedObject valueForKey:attributeName] description];
- cell.selectionStyle = UITableViewCellSelectionStyleNone;
- cell.accessoryType = UITableViewCellAccessoryNone;
+ BOOL isDate = [[[managedObject.entity attributesByName] objectForKey:attributeName] attributeType] == NSDateAttributeType;
+
+ cell.selectionStyle = (isDate ? UITableViewCellSelectionStyleBlue : UITableViewCellSelectionStyleNone);
+ cell.accessoryType = (isDate ? UITableViewCellAccessoryDisclosureIndicator : UITableViewCellAccessoryNone);
}
if ((NSInteger)indexPath.section == DCTManagedObjectViewControllerRelationshipSection) {
@@ -191,26 +196,55 @@ - (void)tableView:(UITableView *)tv didSelectRowAtIndexPath:(NSIndexPath *)index
NSString *attrName = [attributes objectAtIndex:indexPath.row];
NSAttributeDescription *attribute = [[[self.managedObject entity] attributesByName] objectForKey:attrName];
- if (attribute.attributeType == NSStringAttributeType)
+ switch (attribute.attributeType)
{
- UILabel *label = [[tv cellForRowAtIndexPath:indexPath] detailTextLabel];
- UITextField *textField = self.textField;
- textField.backgroundColor = label.backgroundColor;
- textField.text = label.text;
- textField.font = label.font;
- textField.textColor = label.textColor;
-
- CGRect frame = label.frame;
- frame.size.width = label.superview.bounds.size.width - frame.origin.x;
- textField.frame = frame;
- [label.superview addSubview:textField];
-
- textField.tag = indexPath.row;
- [textField becomeFirstResponder];
+ case NSStringAttributeType:
+ {
+ UILabel *label = [[tv cellForRowAtIndexPath:indexPath] detailTextLabel];
+ UITextField *textField = self.textField;
+ textField.backgroundColor = label.backgroundColor;
+ textField.text = label.text;
+ textField.font = label.font;
+ textField.textColor = label.textColor;
+
+ CGRect frame = label.frame;
+ frame.size.width = label.superview.bounds.size.width - frame.origin.x;
+ textField.frame = frame;
+ [label.superview addSubview:textField];
+
+ textField.tag = indexPath.row;
+ [textField becomeFirstResponder];
+ break;
+ }
+
+ case NSDateAttributeType:
+ {
+ DCTDatePickerViewController *detail = [[DCTDatePickerViewController alloc] init];
+ detail.date = [self.managedObject valueForKey:attrName];
+
+ UIBarButtonItem *save = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSave target:self action:@selector(saveDate)];
+ detail.navigationItem.rightBarButtonItem = save;
+ [save release];
+
+ [self.navigationController pushViewController:detail animated:YES];
+ [detail release];
+
+ _editingDateRow = indexPath.row;
+ }
}
}
}
+- (void)saveDate;
+{
+ NSString *attrName = [attributes objectAtIndex:_editingDateRow];
+
+ [self.managedObject setValue:[(DCTDatePickerViewController *)self.navigationController.topViewController date]
+ forKey:attrName];
+
+ [self.tableView reloadData];
+}
+
#pragma mark - Lifecycle
- (void)dealloc {
Please sign in to comment.
Something went wrong with that request. Please try again.