CodePrimate
CodePrimate

Reputation: 6666

exc_BAD_ACCESS(code=1) App crashed on iOS6

I recently took over an iOS project that seems to be crashing whenever I return to the previous view from my PDWViewController by clicking on the partial curl. I get the following error :

http://i.imgur.com/xow29.png

I am sorry for the lacking amount of information I am able to provide but as I only recently began developing for iOS and took over this entire project less than a week ago. Here is what I think is relevant though :

PDFViewController

- (void)viewDidLoad
{

[super viewDidLoad];
// Do any additional setup after loading the view.

itemObjectsInApp =[CoreDataHelper getObjectsForEntity:@"Item" withSortKey:nil andSortAscending:YES andContext:managedObjectContext];

Item *selectedItem = nil;

for(Item *item in itemObjectsInApp){
    if(item.isSelectedItem == [NSNumber numberWithInt:1]){
        selectedItem = item;
    }
}

NSString *path = [[NSBundle mainBundle] pathForResource:selectedItem.pathToPdfFile ofType:@"pdf"];
NSURL *targetURL = [NSURL fileURLWithPath:path];
NSURLRequest *request = [NSURLRequest requestWithURL:targetURL];

[self.pdfView loadRequest:request];

[selectedItem release];
}

MainViewController

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
PdfViewController *pdfViewController = (PdfViewController *)[segue destinationViewController];
pdfViewController.managedObjectContext = managedObjectContext;
}

Upvotes: 0

Views: 1880

Answers (1)

jMelnik
jMelnik

Reputation: 1055

The EXC_BAD_ACCESS is caused by an incorrect memory access.

Try to remove that

[selectedItem release]; 

and see if it works.

Than, if it works, you'll have to release that object after it was used, maybe with an autorelease or something.

Upvotes: 1

Related Questions