-[NADView retain]: message sent to deallocated instance
というエラーメッセージが出ます。
どうも、生成したインスタンスの解放がうまくいってないようなのですが、チュートリアル等をいくら読んでも解答が見つけられませんでした。
「autoreleaseされたオブジェクトにreleaseを送ってはいけない。」という鉄則
から考えると必要なさそうな箇所があるのですが、チュートリアル等では必須なので削除をためらっています。
コードを下記に記載しますので、何か解決策はありませんでしょうか?
//.h
#import <UIKit/UIKit.h>
#import <CoreData/CoreData.h>
#import "GADBannerView.h"
#import "NADView.h"
@interface Menue2ViewController : UITableViewController<UITableViewDataSource, UITableViewDelegate,NADViewDelegate>
{
UITableView *_tableView;
NADView *nadView_;
NSArray *dataMain1;
NSArray *dataDetail1;
GADBannerView *bannerView_;
}
@property (nonatomic, retain) UITableView *_tableView;
@property (nonatomic, retain) NADView *nadView_;
@property (nonatomic, retain) GADBannerView *bannerView_;
@end
//.m
#define MY_BANNER_UNIT_ID @"*************";
@synthesize _tableView;
@synthesize nadView_;
@synthesize bannerView_;
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
return 50;
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
// (2) NADView の作成
nadView_ = [[NADView alloc] initWithFrame:CGRectMake(0,0,
NAD_ADVIEW_SIZE_320x50.width, NAD_ADVIEW_SIZE_320x50.height )];
// (3) set apiKey, spotId.
[nadView_ setNendID:@"a6eca9dd074372c898dd1df549301f277c53f2b9" spotID:@"3172"];
//⬆テスト用
[nadView_ setDelegate:self]; //(4)
[nadView_ setRootViewController:self]; //(5)
[nadView_ load:nil]; //(6)
//例) 問い合わせエラー時には 60秒間隔で再問い合わせする
// [nadView_ load:[NSDictionary dictionaryWithObjectsAndKeys:@"60", @"retry", nil]];
[self.view addSubview:nadView_]; // 最初から表示する場合
return nadView_;
}
- (void) dealloc { //この部分に不安要素があります。
_nadView.delegate = nil;
[_nadView release];
[super dealloc];
}
-(void)nadViewDidFinishLoad:(NADView *)adView {
NSLog(@"NENDLoad成功");
}
-(void)nadViewDidReceiveAd:(NADView *)adView {
NSLog(@"NEND取得成功");
}
-(void)nadViewDidFailToReceiveAd:(NADView *)adView {
NSLog(@"NEND取得失敗");
nadView_.hidden = YES;
}