title: Local Notification in iphone
body: <p>Previously, I have worked on local notifications, but I got problem in it now. Suppose today, I have to set a notification for 1 day before date : 07/07/2012 in my app. How can I will be able to do that. I’m setting notification like this..</p>
  
  <pre><code>- (IBAction) scheduleNotification:(id) sender {
  
      AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
      NSDateFormatter *formatter = [[[NSDateFormatter alloc]init]autorelease];
  
      for (int i = 0; i&lt; [delegate.viewController.contactList count] ; i++) {
          UILocalNotification *localNotification = [prototypeNotification copy];
          NSString *name = [[delegate.viewController.contactList objectAtIndex:i]objectForKey:NAME_KEY];
          NSString *birthday = [[delegate.viewController.contactList objectAtIndex:i]objectForKey:BIRTHDAY_KEY];
          if (birthday) {
              [formatter setDateFormat:@"MM/dd/yyyy"];
              NSDate *date = [formatter dateFromString:birthday];
              if (date == nil) {
                  [formatter setDateFormat:@"MM/dd"];
                  NSDate *date = [formatter dateFromString:birthday];
              }
              else {
  
              }
              self.alarmTime = [date dateByAddingTimeInterval:10];
              localNotification.fireDate = alarmTime;
              localNotification.timeZone = [NSTimeZone defaultTimeZone];
              localNotification.applicationIconBadgeNumber = 1;
  
              NSString *itemName = @"B'day Alert!!!";
              NSString *msgName = [NSString stringWithFormat:@"Celebrate %@'s B'day",name];
              NSDictionary *userDict = [NSDictionary dictionaryWithObjectsAndKeys:itemName,MessageKey, msgName,TitleKey, nil];
              localNotification.userInfo = userDict;
              localNotification.soundName = self.soundName;
              // Schedule the notification
              [[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
  
          }
  
          else {
  //            write else part
          }
          [localNotification release];
      }
  
  }
  </code></pre>
  
  <p>When I encounter <code>NSDate *date = [formatter dateFromString:birthday];</code> this line , date is not coming accurately,so I’m  not able to set local notification properly. If any thing m doing wrong please, help me out.</p>