Created
November 6, 2012 06:49
-
-
Save ChrisRisner/4023100 to your computer and use it in GitHub Desktop.
iOS Day 12 - 2
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)displayManagedObject:(NSManagedObject *)obj { | |
self.txtName.text = [obj valueForKey:@"name"]; | |
self.txtInfo.text = [obj valueForKey:@"info"]; | |
self.txtNumber.text = [(NSNumber *)[obj valueForKey:@"number"] stringValue]; | |
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; | |
[dateFormatter setDateStyle:NSDateFormatterMediumStyle]; | |
self.lblCreateDate.text = [dateFormatter stringFromDate:[obj valueForKey:@"createDate"]]; | |
self.lblUpdateDate.text = [dateFormatter stringFromDate:[obj valueForKey:@"updateDate"]]; | |
} |
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
- (IBAction)tappedNext:(id)sender { | |
BOOL isNext = false; | |
for (NSManagedObject *obj in fetchedObjects) { | |
if (isNext) { | |
selectedObject = obj; | |
[self displayManagedObject:obj]; | |
return; | |
} else { | |
if (obj == selectedObject) | |
isNext = YES; | |
} | |
} | |
} | |
- (IBAction)tappedPrevious:(id)sender { | |
BOOL isPrevious = false; | |
for (int i = fetchedObjects.count-1; i >=0; i--) { | |
if (isPrevious) { | |
selectedObject = [fetchedObjects objectAtIndex:i]; | |
[self displayManagedObject:selectedObject]; | |
return; | |
} else { | |
if ([fetchedObjects objectAtIndex:i] == selectedObject) | |
isPrevious = YES; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment