Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 通知和发送对象值-初学者帮助_Objective C_Operating System - Fatal编程技术网

Objective c 通知和发送对象值-初学者帮助

Objective c 通知和发送对象值-初学者帮助,objective-c,operating-system,Objective C,Operating System,我在一个名为ConnectionController的类中使用以下代码建立了一个通知中心 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(aChangeCalendarMethod:) name:@"updateCalendar" object:nil]; 在另一个类MonthFieldValidator中有一个发件人 [[NSNotificationCenter defaultCenter]

我在一个名为ConnectionController的类中使用以下代码建立了一个通知中心

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(aChangeCalendarMethod:) name:@"updateCalendar" object:nil];
在另一个类MonthFieldValidator中有一个发件人

[[NSNotificationCenter defaultCenter] postNotificationName:@"updateCalendar" object:self];
MonthFieldValidator有一个名为month的NSString类型的属性,我想将它的值传递回连接控制器

我所能做的就是得到这个

打印testObject的说明: NSObject*testObject=0x405500000000000

而且该对象没有month属性,或者至少我不能访问它

大概我必须使用用户信息?

执行以下操作:

[[NSNotificationCenter defaultCenter] postNotificationName:@"updateCalendar" object:yourMonthStringHere];
将调用的方法是:

-(void)aChangeCalendarMethod:(NSNotification*)notification
{
   NSString *strMonth = (NSString *)[notification object]; //retrieve passed string like this
   //continue other code

}