We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
This is my object class:
@class RKObjectMapping; @interface MVCountryModel : NSObject @property (strong, nonatomic) NSNumber *countryId; @property (strong, nonatomic) NSString *countryName; + (RKObjectMapping *) responseMapping; - (int) integerValue; @end
First of all, i had to implement "integerValue" for displaying the picker in this way:
[MMPickerView showPickerViewInView:self.view withObjects:_countries withOptions:nil objectToStringConverter:^NSString *(id object) { return ((MVCountryModel *)object).countryName; } completion:^(id selectedObject) { MVCountryModel *country = (MVCountryModel *)selectedObject; [_labelCountry setText:country.countryName]; _selectedCountryId = country.countryId; }];
But when a option where selected the app crash on my completion block because it only receive a NSString not an instance of my custom object class.
For make it work i had to change this method in this way:
-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component { if (self.objectToStringConverter == nil) { /* self.onDismissCompletion ([_pickerViewArray objectAtIndex:row]); */ self.onDismissCompletion (self.objectToStringConverter ([self selectedObject])); } else{ /* self.onDismissCompletion (self.objectToStringConverter ([self selectedObject])); */ self.onDismissCompletion ([_pickerViewArray objectAtIndex:row]); } }
It looks so simple that i think i'm doing something wrong, but don't! Hope it helps.
The text was updated successfully, but these errors were encountered:
I was having the same error , and use your solution and work perfect 👍 Thanks
Sorry, something went wrong.
No branches or pull requests
This is my object class:
First of all, i had to implement "integerValue" for displaying the picker in this way:
But when a option where selected the app crash on my completion block because it only receive a NSString not an instance of my custom object class.
For make it work i had to change this method in this way:
It looks so simple that i think i'm doing something wrong, but don't! Hope it helps.
The text was updated successfully, but these errors were encountered: