0

FirstViewController.h

#import "EditLocation.h"

FirstViewController.m

@synthesize currentLocationLabel;

- (IBAction) updateCurrentLocationLabel:(NSString *) location {
    NSLog(@"CLICK");
    currentLocationLabel.text = [NSString stringWithFormat:@"%@", location];
}

EditLocation.h

#import "FirstViewController.h"

EditLocation.m

- (void)alertView:(UIAlertView *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
    if (buttonIndex == 0)
    {
        [self.navigationController updateCurrentLocationLabel: location];
        [self.navigationController popViewControllerAnimated:YES];
    }
}

hi there,

im using a navigation controller + tab bar controller application. which is able to move from PageB(EditLocation) back to PageA(FirstViewCOntroller), there is a UIAlert at PageB when user tab Ok, it will go back to PageA where the label(location) will be updated with the address gotten from location object.

however there is an error and cause my program to crash.

here is the problem shown in the console :

2011-08-03 01:33:23.276 Tab Bar Application[5087:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UINavigationController updateCurrentLocationLabel:]: unrecognized selector sent to instance 0x5a37b70'

please help me solve this problem! thanks in advance! im still a newbie in objective C, so bare with my choice of words and language used.

Vladimir
  • 170,431
  • 36
  • 387
  • 313
Jovi
  • 3
  • 1

1 Answers1

0

The error you are receiving is because you are calling the method on the navigation controller itself. You want to call it on the other UIViewController that has that method. I believe FirstViewController. Here is an example of locating a view controller within the tabs

UITabBarController - How to access a view controller?

When you find the right view controller ie.

if( [vc isKindOfClass:[FirstViewController class]]){
    [vc updateCurrentLocationLabel:location];
}
Community
  • 1
  • 1
utahwithak
  • 6,235
  • 2
  • 40
  • 62
  • ok, but the information is store at the EditLocation.m, im trying to move the information to a label found in FirstViewController.m. *side note, do you know where to find tutorials for searchMap? – Jovi Aug 03 '11 at 09:19