-1

アドバイスをください。

午前

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];

    ....

}
4

1 に答える 1

0

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(noteDate:) name:@"notedaterelatednotification" object:nil]; [nc postNotificationName:@"connectDate" object:self userInfo:dicDate]; の代わりに次のようにしてください。この行....

私はあなたが下の行で知っていることを願っています

    [[NSNotificationCenter defaultCenter] postNotificationName:@"notedaterelatednotification" object:nil userInfo:nil];
于 2011-04-26T12:22:47.770 に答える