2016-05-24 54 views
0

我很新到iOS編程,並與我工作的一個應用程序的深水已經拋出。我的應用程序工作正常,但即使沒有更改代碼,此錯誤消息也開始出現。有人能解釋這裏發生了什麼嗎?瞭解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 

編輯:

通過我的代碼看後似乎錯誤是從豐富媒體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; 
} 
+1

這意味着正在被呼叫類型NSCFDictionary的對象上的稱爲isContentAvailable方法,而是一個NSCFDictionary不具有方法叫做那個。 isContentAvailable在更改時也總是出現在錯誤消息中? – Gruntcakes

+1

很可能您正在使用已釋放的對象。該項目是否使用ARC或舊式版本/ autorelease?無論如何,我要做的第一件事情就是編輯Run Scheme以啓用Diagnostics/Zombie Objects和Address Sanitizer。 – EricS

+0

@ThePumpingLama是isContentAvailable總是出現 – user3074140

回答

-1

錯誤是告訴你,該字典不知道方法'isContentAvailable'。這是真的,除非你創建一個類別(我相信你還沒有創建)。在你的代碼,你已經向我們展示了,有這種methid呼籲「P」,這應是類TJPlacement的。如果在你顯示的代碼中真正引發了這個錯誤,那麼真正的原因在於代碼的其他部分。看起來,'p'不是類TJPlacement,而是類NSDictionary。試着去嘗試一下,找出爲什麼是這個班。

0

您有p定義爲一個屬性,但您正在訪問基本變量_p,它不使用屬性提供的getter/setter函數。

我建議你的所有引用更改爲_pself.p更好的內存管理。