【发布时间】:2011-08-26 02:51:28
【问题描述】:
大家好,有人可以建议如何解决下面代码中的内存泄漏
我已经尝试了几乎所有我能想到的 release 和 autorelease 组合,但每次应用程序崩溃或泄漏仍然存在时
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component{
//get refereance to the textfield
UITextField *currentTextField = (UITextField*)[self.view viewWithTag:200];
//check which picker
if(pickerView.tag ==1)
{
// Only calls the following code if component "0" has changed.
if (component == 0) {
// Sets the global integer "component0Row" to the currently selected row of component "0"
component0Row = row;
// Loads the new values for the selector into a new array in order to reload the data.
newValues = [[NSMutableArray alloc] initWithArray:[pickerData objectForKey:[selectorKeys objectAtIndex:component0Row]]];
currentValues = newValues;
// Reloads the data of component "1".
[pickerView reloadComponent:1];
}
//run the selector logic
[self textFieldDidEndEditing:currentTextField];
}
希望有人可以建议
非常感谢
【问题讨论】:
标签: objective-c memory-leaks nsmutablearray release