我试图让这些信息从一个被调用的类发送ViewController
到另一个类。在viewController
我有一个NSDictionary
叫selectedVenues
. 然后在另一个班级我也有一个NSDictionary
叫selectedVenues
. 我想将信息从ViewController selectedVenues
另一个类的 selectedVenue 发送,但它只返回 null;
ViewController *main = nil;
self.selectedVenue = main.selectedVenues;
NSDictionary *selectedLocation = self.selectedVenue[@"location"];
NSString *selectedLat = selectedLocation[@"lat"];
NSString *selectedLng = selectedLocation[@"lng"];
我现在已经试过了。它仍然无法正常工作
ViewController *main = [[ViewController alloc]initWithNibName:@"ViewController" bundle:nil];
//self.selectedVenue = main.selectedVenues;
NSDictionary *selectedLocation = [main getSelectedVenue:@"location"];
NSString *selectedLat = selectedLocation[@"lat"];
NSString *selectedLng = selectedLocation[@"lng"];
这是我的 viewController 中的方法。
-(NSDictionary *)getSelectedVenue:(NSString *)key;
{
NSIndexPath *selectedIndexPath = [self.tableView indexPathForSelectedRow];
self.selectedVenue= [self.venues objectAtIndex:selectedIndexPath.row];
NSDictionary *selectedLocation = self.selectedVenue[key];
return selectedLocation;
}