我宣布以下变量作为实例变量,并在我的m文件中使用它,但是我收到警告。Obj-C,在线分配的对象的潜在泄漏,警告?
TransparentToolbar *tools;
就行分配的对象的潜在泄漏...
我曾尝试创建一个属性,例如..
@property (nonatomic, retain) TransparentToolbar *tools;
而且synthesize'ing并将其释放,但是我的观点在dealloc结束时崩溃了。
我在做什么错?
编辑在pickerSortingDataCurrent同样的警告......
h
@interface myViewController : UIViewController <UIActionSheetDelegate,
UIPickerViewDelegate, UIPickerViewDataSource, UITableViewDelegate,
UITableViewDataSource, MFMailComposeViewControllerDelegate> {
TransparentToolbar *tools;
NSArray *pickerSortingDataCurrent;
}
@property (nonatomic, retain) TransparentToolbar *tools;
@property (nonatomic, retain) NSArray *pickerSortingDataCurrent;
m
@synthesize pickerSortingDataCurrent;
@synthesize tools;
- (void)viewDidLoad {
[super viewDidLoad];
tools = [[[TransparentToolbar alloc]
initWithFrame:CGRectMake(0, 0, 70, 44.01)] autorelease];
tools.barStyle = UIBarStyleBlackOpaque;
self.pickerSortingDataCurrent = [[NSArray alloc] initWithObjects:
@"Next Date Ascending",
@"Next Date Descending", nil]; // removed some items here
}
- (void)dealloc {
[tools release];
[pickerSortingDataCurrent release];
[super dealloc];
}
AHHHH我已经自动释放....但这并不解决pickerSortingDataCurrent ...
编辑...
#import "TransparentToolbar.h"
@implementation TransparentToolbar
- (void)drawRect:(CGRect)rect {
// do nothing in here
}
- (void) applyTranslucentBackground
{
self.backgroundColor = [UIColor clearColor];
self.opaque = NO;
self.translucent = YES;
}
- (id) init
{
self = [super init];
[self applyTranslucentBackground];
return self;
}
// Override initWithFrame.
- (id) initWithFrame:(CGRect) frame
{
self = [super initWithFrame:frame];
[self applyTranslucentBackground];
return self;
}
@end
其他编辑
很难不代码说。 – Max
你可以包含你的'dealloc'代码吗? – Jef
我遇到了同样的问题,我在viewDidLoad中填充了一个接口数据数组,请参阅上面的编辑。 – Jules