gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 02:04:55 25 4
gpt4 key购买 nike

在实现 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com