Мне интересно, как я могу передать 2 строки через моего делегата? Я хочу передать его из viewcontroller2 (SelectStationViewController) в viewcontroller1 (SubGabViewController).
У меня сейчас работает, просто передаю 1 строку (NSString * test).
Вот код, который я настроил:
// in SelectStationViewController.h
@protocol SelectStationViewControllerDelegate;
...
@interface ... {
id <SelectStationViewControllerDelegate> delegate;
}
@property (nonatomic, assign) id <SelectStationViewControllerDelegate> delegate;
@end
@protocol SelectStationViewControllerDelegate
- (void)selectStationViewControllerDidFinish:(NSString *)selectedStationName;
@end
// in SelectStationViewController.m
NSString *test = [[copyListOfItems objectAtIndex:indexPath.row] objectForKey:@"hash"];
[delegate selectStationViewControllerDidFinish:test];
// in SubGabViewController.h
@interface...<SelectStationViewControllerDelegate>
// in SubGabViewController.m
// set selectedStationName as currentStationName
- (void)selectStationViewControllerDidFinish:(NSString *)selectedStationName
{
NSLog(@"selectedStationName is = %@", selectedStationName);
[self setCurrentStationName:selectedStationName];
}
Чтобы передать делегату 2 строки, я бы сделал что-то подобное?
// in SelectStationViewController.m
NSString *test = [[copyListOfItems objectAtIndex:indexPath.row] objectForKey:@"hash"];
NSString *test2 = [[copyListOfItems objectAtIndex:indexPath.row] objectForKey:@"linehash"];
[delegate selectStationViewControllerDidFinish:test];
[delegate selectLineViewControllerDidFinish:test2];
а затем настроить другую функцию, подобную этой?
- (void)selectStationViewControllerDidFinish:((NSString *)selectedStationName;
- (void)selectLineViewControllerDidFinish:((NSString *)selectedLineName;