ios - 实现 tapjoy 分析代码后可达性代码中的应用程序崩溃

标签 ios objective-c reachability tapjoy

在实现 tapjoy 分析工具后,我的应用程序在下面的 Reachability 代码中崩溃了

//Called by Reachability whenever status changes.
- (void) reachabilityChanged: (NSNotification* )note
{
    _changeReachability = YES;
    Reachability* curReach = [note object];
    NSParameterAssert([curReach isKindOfClass: [Reachability class]]);// Application crash here
    [self updateInterfaceWithReachability: curReach];

    if (!isNetAvailable)
    {
        NSLog(@"Disconnect");
    }
    else
    {
        NSLog(@"Connect");
    }
} 

当我打印 NSParameterAssert 日志时,它会说如下内容。

*** Assertion failure in -[AppDelegate reachabilityChanged:],

当我打印通知时,它会像这样打印值。

NSConcreteNotification 0x7e070470 {name = >kNetworkReachabilityChangedNotification; object = 0x7a67e070>}

我怎样才能摆脱这个问题?我想要 tapjoy 和 Reachability。

出现以下错误。

2015-04-27 15:37:18.485 TravAlarm[784:30364] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: [curReach isKindOfClass: [Reachability class]]'
*** First throw call stack:
(
    0   CoreFoundation                      0x05b14946 __exceptionPreprocess + 182
    1   libobjc.A.dylib                     0x05799a97 objc_exception_throw + 44
    2   CoreFoundation                      0x05b147da +[NSException raise:format:arguments:] + 138
    3   Foundation                          0x02991810 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 118
    4   TravAlarm                           0x001ef3dc -[AppDelegate reachabilityChanged:] + 348
    5   Foundation                          0x028cbc49 __57-[NSNotificationCenter addObserver:selector:name:object:]_block_invoke + 40
    6   CoreFoundation                      0x05adf4a4 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 20
    7   CoreFoundation                      0x059cd03b _CFXNotificationPost + 3051
    8   Foundation                          0x028bb246 -[NSNotificationCenter postNotificationName:object:userInfo:] + 98
    9   Foundation                          0x028d801e -[NSNotificationCenter postNotificationName:object:] + 56
    10  TravAlarm                           0x002e15ce ReachabilityCallback + 462
    11  SystemConfiguration                 0x04535b32 reachPerform + 559
    12  CoreFoundation                      0x05a381df __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
    13  CoreFoundation                      0x05a2dced __CFRunLoopDoSources0 + 253
    14  CoreFoundation                      0x05a2d248 __CFRunLoopRun + 952
    15  CoreFoundation                      0x05a2cbcb CFRunLoopRunSpecific + 443
    16  CoreFoundation                      0x05a2c9fb CFRunLoopRunInMode + 123
    17  GraphicsServices                    0x0617224f GSEventRunModal + 192
    18  GraphicsServices                    0x0617208c GSEventRun + 104
    19  UIKit                               0x045d08b6 UIApplicationMain + 1526
    20  TravAlarm                           0x000d35ed main + 141
    21  libdyld.dylib                       0x063b7ac9 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

最佳答案

能否请您添加此代码并再次检查。它可能对您有帮助。

//Called by Reachability whenever status changes.
- (void) reachabilityChanged: (NSNotification* )note
{
    _changeReachability = YES;
Reachability* curReach = [note object];
    if ([curReach isKindOfClass:[Reachability class]])
    {
        NSParameterAssert([curReach isKindOfClass: [Reachability class]]);
        [self updateInterfaceWithReachability: curReach];
        
        if (!isNetAvailable)
        {
            NSLog(@"Disconnect");
        }
        else
        {
            NSLog(@"Connect");
        }
    }
    
}

快乐编码...

关于ios - 实现 tapjoy 分析代码后可达性代码中的应用程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29892665/

相关文章:

ios - 如何将任意颜色的色度键滤镜应用到实时摄像头源ios?

iphone - 在 iOS 应用程序中将用户输入的数字显示为上标

ios - Swift:传递 C 函数 (SCNetworkReachabilityCallBack)

iphone - 应用程序因音频流超过 5MB/5 分钟而被拒绝?可达性和跟踪数据使用情况

ios - 使用 Xcode 5 更新应用

ios - 在 iPhone 上使用蓝牙 5

ios - 计算属性生成 "Overriding declaration requires an ' 重写“关键字”错误

objective-c - iOS http post 对 NSDictionary 或 NSArray 的响应

objective-c - Xcode 类不能 "see"彼此

objective-c - 可达性误报问题