Ios 可达性改变导致崩溃
苹果开发者可访问性示例在我的应用程序中播放离线音乐时关闭wifi()会导致内存泄漏,我在下面提到的线路被卡住了,这可能是由于播放器代码引起的,因为日志显示Ios 可达性改变导致崩溃,ios,memory-leaks,nsnotificationcenter,reachability,Ios,Memory Leaks,Nsnotificationcenter,Reachability,苹果开发者可访问性示例在我的应用程序中播放离线音乐时关闭wifi()会导致内存泄漏,我在下面提到的线路被卡住了,这可能是由于播放器代码引起的,因为日志显示[\u NSCFString reachabilityDidChange:]:无法识别的选择器 [[NSNotificationCenter defaultCenter]postNotificationName:kReachabilityChangedNotification对象:noteObject] 在这种方法中: static void
[\u NSCFString reachabilityDidChange:]:无法识别的选择器
[[NSNotificationCenter defaultCenter]postNotificationName:kReachabilityChangedNotification对象:noteObject]代码>
在这种方法中:
static void ReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags flags, void* info)
{
#pragma unused (target, flags)
NSCAssert(info != NULL, @"info was NULL in ReachabilityCallback");
NSCAssert([(__bridge NSObject*) info isKindOfClass: [CDVReachability class]], @"info was wrong class in ReachabilityCallback");
CDVReachability* noteObject = (__bridge CDVReachability *)info;
// Post a notification to notify the client that the network reachability changed.
[[NSNotificationCenter defaultCenter] postNotificationName: kReachabilityChangedNotificationString object: noteObject];
}
以下是日志:
2015-04-12 19:52:03.416 HelloCordova[4094:1250289] -[__NSCFString reachabilityDidChange:]: unrecognized selector sent to instance 0x174232820
而reachabilityDidChange
就在这里
我不知道这是否正确,但我尝试了以下方法:
dispatch_async(dispatch_get_main_queue(), ^{
[[NSNotificationCenter defaultCenter] postNotificationName:kReachabilityChangedNotification object:noteObject];
});}
即使这样:
// We're on the main RunLoop, so an NSAutoreleasePool is not necessary, but is added defensively
// in case someon uses the Reachability object in a different thread.
@autoreleasepool {
Reachability* noteObject = (__bridge Reachability*)info;
// Post a notification to notify the client that the network reachability changed.
[[NSNotificationCenter defaultCenter] postNotificationName:kReachabilityChangedNotification object:noteObject];
}
嗨,我也有同样的问题,你能告诉我你是怎么解决的吗?
// We're on the main RunLoop, so an NSAutoreleasePool is not necessary, but is added defensively
// in case someon uses the Reachability object in a different thread.
@autoreleasepool {
Reachability* noteObject = (__bridge Reachability*)info;
// Post a notification to notify the client that the network reachability changed.
[[NSNotificationCenter defaultCenter] postNotificationName:kReachabilityChangedNotification object:noteObject];
}