Tsuichi5 Posted May 14, 2008 Share Posted May 14, 2008 I'm having a problem creating a class that has an assigned callback with a (SEL) object. Basically, I'm creating a custom UIPicker object that contains the array of objects to select from, and use a callback to identify when the selector item has been chosen, and the dialog box is to be removed from the screen. What I'm trying to do is: - (void)loadView { NSArray *array = [NSArray initWithObjects: @"Test 1", @"Test 2", nil]; CustomPicker *picker = [[CustomPicker alloc] initWithArray:array]; [picker actionSelected:@selector(selectedFirstPicker:)]; } - (void)selectedFirstPicker:(id)sender { NSLog(@"Picker selected! Congradulations.\n"); } I can *set* the object inside my interface by saying: @interface CustomPicker : UIPickerViewDelegate { SEL onClick; } And when I try calling the "onClick" object, it blows up in my face: - (void)actionSelected:(SEL)object { onClick = object; } - (void)callClick { [self performSelector:onClick withObject:self]; } But the SDK doesn't like that, it dies on objc_send. Does anyone have a working example of this? Or can anyone tell me what I'm doing wrong? Maybe I need to create the "onClick" object as a property, and synthesize it in the class? I looked over the docs from Apple and they're technically very vague. Not sure what I am doing wrong. Link to comment https://www.insanelymac.com/forum/topic/104867-creating-callbacks-messages-with-sel/ Share on other sites More sharing options...
Tsuichi5 Posted May 15, 2008 Author Share Posted May 15, 2008 Further research shows: [self performSelector:onClick]; Throws a huge exception. [self.parentViewController performSelector:onClick]; Does nothing. Also, [respondsToSelector:doneCallback] returns false. PLEASE. I *HOPE* someone can help. I've asked several questions, and they receive absolutely no responses. I hope this isn't some strange topic that no one's ever used. Link to comment https://www.insanelymac.com/forum/topic/104867-creating-callbacks-messages-with-sel/#findComment-747017 Share on other sites More sharing options...
Tsuichi5 Posted May 16, 2008 Author Share Posted May 16, 2008 Never mind, all, figured it out. Link to comment https://www.insanelymac.com/forum/topic/104867-creating-callbacks-messages-with-sel/#findComment-748581 Share on other sites More sharing options...
Aatif Posted September 30, 2008 Share Posted September 30, 2008 how u figured it out? I also want to use some custom picker to enable user to select from a list of items ... Link to comment https://www.insanelymac.com/forum/topic/104867-creating-callbacks-messages-with-sel/#findComment-911696 Share on other sites More sharing options...
Recommended Posts