Maybe it is silly question, but I have an curious problem. My app fails every time I try to refresh my data in database using core data when I re-enter the view controller. If I enter the view controller and refresh data from internet it works. However, when I start the program, enter the view controller, then pop it and re-enter and try refresh data, it fails and nothing is logged in view controller. I do not know why it happens. So I tried to debug it but the problem disappeared. After I tried again without debug mode it failed once more. I do not know why. Could it be problem of allocation, or something not released? Here’s my implementation of -viewDidLoad:
- (void)viewDidLoad {
pool = [[NSAutoreleasePool alloc] init];
if (managedObjectContext_ == nil)
{
managedObjectContext_ = [[(NavTestAppDelegate *)[[UIApplication sharedApplication] delegate] managedObjectContext] autorelease];
}
UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:@selector(insertNewObject)];
self.navigationItem.rightBarButtonItem = addButton;
[addButton release];
prikazDatabaseArray = [[[NSMutableArray alloc] init]retain];
NSDate *now = [NSDate date];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"dd.MM.yyyy"];
datumOd = [[dateFormatter stringFromDate:now] retain];
[dateFormatter release];
VObrat = YES;
}
I also use
NSAutoreleasePool *pool;
NSURLConnection *theConnection;
NSMutableURLRequest *theRequest;
NSData *xmlData;
NSData *xmlFile;
NSXMLParser *addressParser;
in my code. If you could, at least help me find where I have the problem, because without debug and console I feel like a blind man.
Thanks a lot
if you are creating your own pool then you need to release the pool in the same context or method or loop.
you should use [pool drain] for that.
if you are not able to see your crash log you run with performance tool it will give you the location where u are doing wrong.