ios - 'EXC_BAD_ACCESS code=2' 尝试将对象从 VC 设置为另一个时发生错误

标签 ios objective-c exc-bad-access

假设我有 2 个 ViewController:A 和 B。

这是A的一些代码:

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle: nil];
CategoryVC *vc = [storyboard instantiateViewControllerWithIdentifier:@"categoryVC"];
PParser *destPP = [[PParser alloc] init];
[destPP initWithFullURL:@"http://someurl.com"];
//setPp gives the Error EXC_BAD_ACCESS
[vc setPp:destPP];
SWRevealViewControllerSeguePushController *segue = [[SWRevealViewControllerSeguePushController alloc] initWithIdentifier:@"ANY_ID" source:self destination:vc];
[segue perform];

这是B的一些代码:

-(void)setPp:(PParser *)pp{
    self.pp = pp;
}

我猜这个错误与未正确设置的指针有关?为什么会出现此错误,我应该如何解决它?

最佳答案

试试这个:

-(void)setPp:(PParser *)pp  
{
  _pp = pp;
}

关于ios - 'EXC_BAD_ACCESS code=2' 尝试将对象从 VC 设置为另一个时发生错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38995085/

相关文章:

ios - 在 iOS 中将 NSMutableDictionary 添加到 NSMutableArray 时崩溃?

c++ - C++ : Attempting to add new node to linked list yields “Thread 1: EXC_BAD_ACCESS (code=1, address=0x0)” error

ios - 只能接受一个参数的 NSLog 宏

ios - UICollectionView 重新排序不可移动的单元格问题

iphone - zBar Camera中的Flash

ios - 如何在 Objective C 的循环中为按钮重复动画?

ios - 方法确实在父 View Controller 中调用,但方法内部的逻辑从不执行任何操作

ios - NSNotificationCenter 的帖子导致 "EXC_BAD_ACCESS"异常

ios - 返回上一 View 时应用程序崩溃 - 线程 1 : EXC_BAD_ACCESS

ios - 当通过 UIRefreshControl 调用时,UITableView 重新加载会重复 NSMutableArray 的值