引用计数对象在被释放后使用

时间:2021-06-10 01:18:07

I am getting memory warning as "Reference counted object is used after being it is released"

我收到内存警告“引用计数对象在被释放后使用”

For this i have tried autorelease also. but no use.

为此我也试过autorelease。但没用。

below is the code which gives my warning.what is the issue. pls let me know

下面是给出警告的代码。问题是什么。请告诉我

UICustomSwitch *switchView = [[UICustomSwitch alloc] initWithFrame:CGRectZero];
                [switchView initWithFrame:CGRectMake(180,5,260,30)];
                [switchView setOn:YES];
                mySearchType = 1;
                [[switchView rightLabel] setFont:[UIFont fontWithName:@"Georgia" size:16.0f]];
                [[switchView leftLabel] setFont:[UIFont fontWithName:@"Georgia" size:16.0f]];
                [switchView addTarget:self action:@selector(switchToggled:)forControlEvents:UIControlEventValueChanged];
                [cell.contentView addSubview:switchView];

1 个解决方案

#1


3  

change the following code

更改以下代码

UICustomSwitch *switchView = [[UICustomSwitch alloc] initWithFrame:CGRectZero];
                [switchView initWithFrame:CGRectMake(180,5,260,30)];

into

UICustomSwitch *switchView = [[UICustomSwitch alloc] initWithFrame:CGRectMake(180,5,260,30)];

#1


3  

change the following code

更改以下代码

UICustomSwitch *switchView = [[UICustomSwitch alloc] initWithFrame:CGRectZero];
                [switchView initWithFrame:CGRectMake(180,5,260,30)];

into

UICustomSwitch *switchView = [[UICustomSwitch alloc] initWithFrame:CGRectMake(180,5,260,30)];