Local Declaration “x” hides instance variable xcod

2019-03-17 09:16发布

问题:

I've been have trouble understand this problem. If I change the variable name fifthViewController the error goes away but the view controller doesn't load.

Lost. Once again it's probably something simple.

Thanks in advance.

Here is the code:

{
FifthViewController *fifthViewController = [[FifthViewController alloc] initWithNibName:@"FifthView" bundle:nil];

fifthViewController.transactionID = transactionID;
[self.navigationController pushViewController:fifthViewController animated:NO]; 
[fifthViewController release];
 }

回答1:

This means the variable fifthViewController is named the same as something else in your class implementation. If you mean to use that variable, drop the FifthViewController* type declaration off the first line; otherwise, change the name fifthViewController everywhere it appears in that method.