【发布时间】:2016-03-04 14:36:43
【问题描述】:
我已经在我的应用中实现了locationKit (locationKit.io) SDK。
我有一个 NSNotificationCenter 观察者,它在两个不同的类中调用两个选择器(基本上,将数据从一个类传递到另外两个类)。
当我使用CLLocationManager 时,一切正常,但是当我切换到LKLocationManager 时,只有一个选择器被调用(第一类中的选择器工作正常,但第二类中的选择器没有被调用完全)。
当我切换回CLLocationManager 时,一切都恢复正常了。
我的LKLocationManagerAppDelegate.m:
-(BOOL)application:(UIApplication *)application willFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.locationManager=[[LKLocationManager alloc] init];
self.locationManager.apiToken=@"myAPIToken";
}
在firstGetterClass.m 中创建观察者:(工作中)
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(getArrays:) name:@"callGetArrays:" object:nil];
在secondGetterClass.m 中创建观察者:(不工作)
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(getArrays:) name:@"callGetArrays:" object:nil];
从senderClass.m发送帖子通知:
-(void)sendAllStoresAndCategories
{
NSDictionary *arrayDictionary=[NSDictionary dictionaryWithObjectsAndKeys:self.arrayToSend,@"arrayToSend", nil];
[[NSNotificationCenter defaultCenter]postNotificationName:@"callGetArrays:" object:nil userInfo: arrayDictionary];
}
有人知道出了什么问题吗?
谢谢!
【问题讨论】:
标签: ios objective-c iphone cocoa-touch nsnotificationcenter