0

I am trying to pass object by reference (or pointer to object) to another view controller.
This is how I am trying to pass it:

SecondViewController* ctrl = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil andParam:&self.sharedLocationHandler];

And this is my init at second view controller:

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil andParam:(TTLocationHandler**)aParam {
    [self.sharedLocationHandler.locationManager startUpdatingLocation];
    return self;
}

Error that I am getting:

Address of property expression expected

What I did wrong here?

1110
  • 7,829
  • 55
  • 176
  • 334
  • Did you accidentally post the same code snippet twice? Where is the init method? – CrimsonChris May 30 '14 at 06:24
  • What possible reason would a view controller need a singleton passed to it by reference? Perhaps there is a better way to do whatever it is you're doing. – CrimsonChris May 30 '14 at 06:32
  • @CrimsonChris yes I have updated question wrong copy. Maybe there is a better way this question is connected to this one http://stackoverflow.com/questions/23940557/when-close-view-that-started-locations-service-notification-error-occure – 1110 May 30 '14 at 06:41
  • I'm not seeing any reason why you would need to use pass by reference here. – CrimsonChris May 30 '14 at 06:42
  • @CrimsonChris When I run location services at second view and close it location service try to send notification and my app crash as second view is dismissed. I get suggestion to pass object by ref if you think that there is better way please help :) – 1110 May 30 '14 at 06:44
  • I'd recommend posting a new question. Include all your relevant code. – CrimsonChris May 30 '14 at 06:49
  • Am I missing something or is the call to super initWithNibName missing ? – Blitz May 30 '14 at 06:53

1 Answers1

0

You cannot not pass pointer to a property as properties are essentially getter-setter methods... pass pointer to the variable... check this answer for more details

Community
  • 1
  • 1
Swapnil Luktuke
  • 10,385
  • 2
  • 35
  • 58