Jump to content
4 posts in this topic

Recommended Posts

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.

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.

  • 4 months later...
×
×
  • Create New...