iPhone開発初心者です。シングルトーンクラスを使用しているアプリケーションを開発しています。シングル トーン クラスのオブジェクトを作成しているときに、コードの分析時にメモリ リークが発生します。「オブジェクトの潜在的なリーク」および「割り当てられたオブジェクトは後で参照されません」というメッセージを出しています。しかし、コードでそのオブジェクトを使用しています。以下は、シングルトーンクラスオブジェクトを作成した私のコードです
- (void)viewDidLoad
{
[super viewDidLoad];
NSLog(@"Inside View");
self.navigationController.navigationBar.topItem.title = @"Menu List";
UIImage *image = [UIImage imageNamed:@"Navigation_bar.png"];
[_bgImage setFrame:CGRectMake(0,-45,320,510)];
[self.navigationController.navigationBar setBackgroundImage:image
forBarMetrics:UIBarMetricsDefault];
[self.tabBarController.tabBar setBackgroundImage:[UIImage imageNamed:@"Tab_bar.png"]];
[self.navigationItem setHidesBackButton:YES];
menuTableView.backgroundColor=[UIColor clearColor];
menuTableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
_hotelMenu=[SharedHotelMenu sharedInstanceMethod];
_queryFormatter=[[DatabaseQueryFormatter alloc]init];
_isSearchOn=NO;
_searchResult=[[NSMutableArray alloc]init];
_categorySearch.layer.cornerRadius = 19;
_categorySearch.clipsToBounds = YES;
_categorySearch.delegate=self;
UIView *_paddingView=[[UIView alloc] initWithFrame:CGRectMake(0,0,5,10)];
_categorySearch.leftView=_paddingView;
_categorySearch.leftViewMode=UITextFieldViewModeAlways;
[_paddingView release];
UIView *_paddingRightView=[[UIView alloc] initWithFrame:CGRectMake(0,0,30,10)];
_categorySearch.rightView=_paddingRightView;
_categorySearch.rightViewMode=UITextFieldViewModeAlways;
[_paddingRightView release];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(searchBar)
name:UITextFieldTextDidChangeNotification object:_categorySearch];
}
}
シングル トーン クラス オブジェクトを _hotelMenu=[SharedHotelMenu sharedInstanceMethod]; として作成しました。