-1

give me some advice, plz.

A.m

NSDate *todayDate = [NSDate date];

NSDateFormatter *dateFormat = [[[NSDateFormatter alloc]init]autorelease];
        [dateFormat setDateFormat:@"yy-MM-dd"];
        todayString = [dateFormat stringFromDate:todayDate];
        NSLog(@"today : %@", todayString);



NSDictionary *dicDate = [NSDictionary dictionaryWithObject:todayDate forKey:@"keyDate"];
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
[nc postNotificationName:@"connectDate" object:self userInfo:dicDate];



B.m

- (void)noteDate:(NSNotification *)date {

    NSLog(@"notification");
    NSDate *startDate = [[date userInfo] objectForKey:@"keyDate"];

    stampDate = [[[NSDate alloc]init]retain];

    NSLog(@"savedDate : %@", startDate);
    self.stampDate = startDate;

    NSLog(@"notification date : %@", stampDate);


}



- (void)viewDidLoad {

    [super viewDidLoad];

    NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
    [nc addObserver:self selector:@selector(noteDate:) name:@"connectDate" object:nil];

    ....

}
Adnan
  • 25,882
  • 18
  • 81
  • 110
  • please format your code - makes it much easier to read. Secondly, be a bit more verbose. What does your code, what would you expect? What did you try? – Axel Apr 26 '11 at 12:18
  • This question is very funny :D. You're asking for advice but, an advice about what? – HyLian Apr 26 '11 at 12:20
  • Is the postNotificationName line getting executed? Put a breakpoint there and make sure. How and where is class A being instantiated by B? –  Apr 26 '11 at 13:54

1 Answers1

0

Try like this [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(noteDate:) name:@"notedaterelatednotification" object:nil]; instead of [nc postNotificationName:@"connectDate" object:self userInfo:dicDate]; this line....

i hope you aware with the below line

    [[NSNotificationCenter defaultCenter] postNotificationName:@"notedaterelatednotification" object:nil userInfo:nil];
ajay
  • 3,245
  • 4
  • 31
  • 59