ビューコントローラー間のデータの受け渡しにはデリゲートメソッドを使用しました。これは機能していません。
@protocol PassCountry <NSObject>
@required
- (void) setPickedCountry:(NSString *)pickedCountry;
@end
@interface SelectCountryViewController : UIViewController<UIPickerViewDelegate, UIPickerViewDataSource> {
id <PassCountry> delegate;
}
@property (copy) NSString *pickedCountry;
@property (retain) id delegate;
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent (NSInteger)component {
pickedCountry = [self.countries objectAtIndex:row];
}
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component {
return self.countries.count;
}
- (void)viewWillDisappear:(BOOL)animated {
[[self delegate] setPickedCountry:pickedCountry];
}