简体   繁体   中英

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;
}

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM