了解iOS错误消息

时间:2016-05-24 04:31:17

标签: ios objective-c xcode

我是iOS编程的新手,并且已经被我正在开发的应用程序抛到了深处。我的应用程序工作正常,但即使我没有更改代码,此错误消息也开始出现。有人能解释一下这里发生了什么吗?

错误消息有时不同,“ _NSCFDictionary ”是“ OS_dispatch_queue _ ”或“ _NSMallocBlock ”等。它似乎永远不会两次相同。我试过清理这个项目无济于事。

2016-05-24 13:28:12.761 dam[1357:648017] -[__NSCFDictionary isContentAvailable]: unrecognized selector sent to instance 0x1570c52d0
2016-05-24 13:28:12.768 dam[1357:648017] WARNING: GoogleAnalytics 3.08 void GAIUncaughtExceptionHandler(NSException *)      
(GAIUncaughtExceptionHandler.m:49): Uncaught exception: -[__NSCFDictionary isContentAvailable]: unrecognized selector sent to instance 0x1570c52d0
2016-05-24 13:28:13.753 dam[1357:648017] -[__NSCFDictionary isContentAvailable]: unrecognized selector sent to instance 0x1570c52d0
libc++abi.dylib: terminate_handler unexpectedly threw an exception

编辑:

查看我的代码后,似乎错误来自Tapjoy SDK。错误似乎发生在使用_p = 0的准备好的方法中。

#import <UIKit/UIKit.h>
#import "MovieReward6005.h"

#import <Tapjoy/Tapjoy.h>

@interface MovieReward6005()<TJPlacementDelegate, TJCVideoAdDelegate>
@property (nonatomic, strong)UIViewController *viewController;
@property (nonatomic, assign)BOOL test_flg;
@property (nonatomic, strong)NSString* placement_id;
@property (nonatomic, strong)TJPlacement* p;

@end

@implementation MovieReward6005

- (id)init{
NSLog(@"MovieReward6005 init");
if(!self){
    self = [super init];

    [Tapjoy startSession];

    // Add an observer for when a user has successfully earned currency.
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(showEarnedCurrencyAlert:)
                                                 name:TJC_CURRENCY_EARNED_NOTIFICATION
                                               object:nil];

    // Best Practice: We recommend calling getCurrencyBalance as often as possible so the user’s balance is always up-to-date.
    [Tapjoy getCurrencyBalance];
}
return self;
}

/**
 * 
 *
 *  @param data
 */
-(void)setData:(NSDictionary *)data{
NSLog(@"MovieReward6005 setData start");
NSLog(@"data : %@",data);

self.viewController = [data objectForKey:@"displayViewContorller"];
NSLog(@"MovieReward6005 connectSetting start");
_p = nil;
//Set up success and failure notifications
[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(tjcConnectSuccess:)
                                             name:TJC_CONNECT_SUCCESS
                                           object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(tjcConnectFail:)
                                             name:TJC_CONNECT_FAILED
                                           object:nil];

BOOL test_flg = [[data objectForKey:@"test_flg"] boolValue];
//    test_flg = YES;
[Tapjoy setDebugEnabled:test_flg];
NSString* connectStr = [data objectForKey:@"sdk_key"];
self.placement_id = [data objectForKey:@"placement_id"];
//The Tapjoy connect call
[Tapjoy connect:connectStr];
NSLog(@"MovieReward6005 connectSetting end");
}

/**
 *  
 */
-(void)startAd
{
//NSLog(@"MovieReward6005 startAd");
if (!self.viewController) {
    return;
}

[Tapjoy setVideoAdDelegate:self];
_p = [TJPlacement placementWithName:_placement_id delegate:self];
_p.adapterVersion = @"1.0.0";
[_p requestContent];

}

-(BOOL)isPrepared{
NSLog(@"MovieReward6005 isPrepared");
NSLog(@"_p.isContentAvailable : %d",_p.isContentAvailable);
return _p.isContentAvailable;
}

2 个答案:

答案 0 :(得分:0)

您已将p定义为属性,但您正在访问基础变量_p,该变量不使用属性提供的getter / setter函数。

我建议您将_p的所有引用更改为self.p,以便更好地进行内存管理。

答案 1 :(得分:-1)

错误告诉你,该词典不知道方法&#39; isContentAvailable&#39;。这是事实,除非你创建一些类别(我相信你没有做过)。在您向我们展示的代码中,有一个名为“p&#39;”的方法,它应该是TJPlacement类。如果在你在那里显示的代码中真的触发了这个错误,那么真正的原因就在于代码的其他部分。看起来,&#39; p&#39;不是TJPlacement类,而是类NSDictionary。试着去解决这个问题并找出原因。