【发布时间】:2012-10-01 19:51:37
【问题描述】:
在我的类 dealloc 方法中,我有
- (void) dealloc
{
[searchField release];
[super dealloc];
}
其中 searchField 在类变量中定义。
@interface SearchCell : UITableViewCell
{
UISearchBar *searchField;
id delegate;
}
类的使用方式如下:
if (indexPath.section == 0)
{
SearchCell *mycell = [[SearchCell alloc] init];
[cell setDelegate:self];
return [mycell autorelease];
}
searchField 在这里创建:
- (id) init
{
self = [super initWithFrame:CGRectZero];
[self create];
return self;
}
- (void) create
{
searchField = [[UISearchBar alloc] initWithFrame:CGRectZero];
searchField.autocorrectionType = UITextAutocorrectionTypeNo;
[self addSubview:searchField];
}
我是否需要使用[searchField release];在我的交易中?应用程序崩溃并显示以下消息:“*[UISearchBar respondsToSelector:]: message sent to deallocated instance *”。
【问题讨论】:
标签: iphone objective-c ios memory-management