I want to do the following thing on button clck :
- (void)alertView:(UIAlertView *)alertView click开发者_如何学JAVAedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 0)
{
if (QuestionMutableArray==nil) {
[self testIterator];
}
else
{
[myMutableArray release];
[myDictionary release];
[self dismissModalViewControllerAnimated:YES];
//[self release];
}
}
}
After going back to the parentView controller with this code...when i am again coming this tableView i want to reload my tableView with new NSMutableArray.How can i empty my collection(NSMutableArray or dictionary) with the dismissModalViewController?
Use removeAllObjects
method.
The EXC_BAD_ACCESS error comes when you try to access memory that has been released. Perhaps you are trying to access the array or dictionary after you've released them. Instead, remove the objects from the array or dictionary.
Don't release it make the object to nil
.
EXC_BAD_ACCESS usually comes from two reasons:
- Strings not beginning with '@' sign and
- Poor memory management.
In your condition, I assume you release the array and dictionary but you are not correctly initializing. Make sure they are properly initialized before every usage, and stay retained until you are done with them. It may also be caused by playing on the interface builder: I remember several times connecting an IBOutlet and decide the name does not make any sense and rename the property. After each connection xcode automatically puts a release statement in the dealloc method, you may also want to check there if you used IB at that view controller, in case a property has been released twice.
精彩评论