【问题标题】:NSNotificationCenter selector isn't being called with locationKitNSNotificationCenter 选择器没有被 locationKit 调用
【发布时间】: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


    【解决方案1】:

    很遗憾,我不太确定我能为您提供什么帮助。

    如果没有看到您的代码如何将所有这些部分组合在一起,或者 LocationKit 如何/为什么会导致问题,这真的很难。在 SocialRadar,我们有使用 NSNotificationCenter 的内部应用程序,还没有看到这个问题。

    此外,我不确定 LocationKit 会如何导致这样的问题,因为我们的 SDK 不会以任何方式触及或更改 NSNotificationCenter。

    您的问题是否更多地在于您在其中触发这些通知的回调没有按照您的预期调用?

    看看我们的open source sample app 可能会很有用,它使用 LocationKit 和 NSNotificationCenter 并且没有任何问题。

    干杯,
    维克多
    SocialRadar 工程副总裁

    【讨论】:

    • 嗨,维克多,我已经给你发了一封电子邮件 :)
    • 嗨@FS.O 我很乐意帮助您解决问题,但您根本没有给我足够的信息来这样做。如果您可以向我发送更多信息,我可以提供帮助,但您在上面提供的信息还不够。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-01
    相关资源
    最近更新 更多