/* // 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 { if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) { // Custom initialization } return self; } */
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib. - (void)viewDidLoad { [super viewDidLoad];
//if we edited lets save the note in case we're exiting for a text or incoming call if(didEdit){ [self savePlist];
} }
/* // Override to allow orientations other than the default portrait orientation. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // Return YES for supported orientations return (interfaceOrientation == UIInterfaceOrientationPortrait); } */
-(void) keyboardDidShow: (NSNotification *)notif { if (keyboardVisible) { //NSLog(@"Keyboard is already visible. Ignoring notofication."); return; }
//The keyboard wasn't visible before
// Get the size of the keyboard. NSDictionary* info = [notif userInfo]; NSValue* aValue = [info objectForKey:UIKeyboardBoundsUserInfoKey]; CGSize keyboardSize = [aValue CGRectValue].size;
if(self.Notedict != nil){ // We're working with an exisitng note, so let's remove // it from the array to get ready for a new one [noteArray removeObject:Notedict]; self.Notedict = nil; //This will release our reference too
}
// Add it to the master array and release our reference [noteArray addObject:newNote];
//important, without this it double creates your saved note on exit due to saving on viewWillDissapear didEdit = NO;
[newNote release];
// Sort the array since we just aded a new drink NSSortDescriptor *nameSorter = [[NSSortDescriptor alloc] initWithKey:@"CDate" ascending:NO selector:@selector(compare:)]; [noteArray sortUsingDescriptors:[NSArray arrayWithObject:nameSorter]]; [nameSorter release];
if(!didEdit) { [self dismissModalViewControllerAnimated:YES]; } else { // open a alert with an OK and cancel button UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Unsaved Changes!" message:@"Close without saving?" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil]; [alert show]; [alert release];
}
}
- (void)alertView:(UIAlertView *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex { // the user clicked one of the OK/Cancel buttons if (buttonIndex == 0) { //NSLog(@"cancel")