- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSLog(@"didselectrowatindexatpath");
Place *placeAtIndex = (Place *)[appDelegate.PlacesArray objectAtIndex:indexPath.row];
NSLog(@"required lat long is %f, %f ", placeAtIndex.PlaceLatitude, placeAtIndex.PlaceLongitude);
returnToMapDelegate = (CortesViewController *)[[UIApplication sharedApplication] delegate];
[returnToMapDelegate showAddress];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath is Called in PlacesViewController.m and Function "showaddress" is defined in CortesViewController.h.
I am getting error "Terminating app due to uncaught exception
'NSInvalidArgumentException', reason: '-[CortesAppDelegate showAddress]: unrecognized selector sent to instance 0x146ce0'"
at line
returnToMapDelegate = (CortesViewController *)[[UIApplication sharedApplication] delegate];
I used successfully following delegate method in code.
CortesAppDelegate *appDelegate = (CortesAppDelegate *)[[UIApplication sharedApplication] delegate];
[appDelegate somefunction] ;
But when I tried sam开发者_如何学编程e thing for CortesViewController, application crashes. I am new to iOS. It might be possible that I am missing very simple point.
Can anyone tell me what is wrong with the code?
Thanks for help in advance
The problem is in following: method [[UIApplication sharedApplication] delegate];
returns object of class CortesAppDelegate
. So you cannot call showAddress
as it is defined in CortesViewController
精彩评论