Created
September 8, 2009 14:09
-
-
Save jfahrenkrug/182942 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)addLocation { | |
if (!locations) { | |
locations = [[CPArray alloc] init]; | |
} | |
loc = [[Location alloc] init]; | |
[loc setDescription:@""]; | |
[loc setPosition:([locations count] + 1)]; | |
[locations addObject:loc]; | |
[locationListView setContent:locations]; | |
[locationListView reloadContent]; | |
[locationListView setSelectionIndexes:[CPIndexSet indexSetWithIndex:([locations count] - 1)]]; | |
} | |
- (void)removeLocation { | |
if (![self selectedLocation]) { | |
return; | |
} | |
if (confirm('Are you sure?')) | |
{ | |
if ([[self selectedLocation] isNewRecord]) { | |
[self removeSelectedLocation]; | |
} else { | |
//we'll implement this later | |
} | |
} | |
} | |
- (void)removeSelectedLocation { | |
[locations removeObjectAtIndex:[[locationListView selectionIndexes] firstIndex]]; | |
[locationListView setContent:locations]; | |
[locationListView reloadContent]; | |
[locationListView setSelectionIndexes:[CPIndexSet indexSetWithIndex:([locations count] - 1)]]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment