why can't I set a new instance's delegate as self?
Posted
by Guille10k
on Stack Overflow
See other posts from Stack Overflow
or by Guille10k
Published on 2010-05-14T05:57:24Z
Indexed on
2010/05/14
6:04 UTC
Read the original article
Hit count: 195
I have a uipickerview, which appears with an ActionSheet. All this is in a class "MultiPicker". I create a new instance from "FirstViewController" this way:
multiPicker *multiPic = [[multiPicker alloc]init];
multiPic.delegate = self;
[multiPic action:aRunIndex];
And inside "multiPicker", in "action:"
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:title delegate:otroDelegate cancelButtonTitle:nil destructiveButtonTitle:@"Cancel" otherButtonTitles:@"Done", nil];
UIPickerView *pickerView = [[[UIPickerView alloc] init] autorelease];
pickerView.tag = 101;
pickerView.delegate = self;
pickerView.dataSource = self;
pickerView.showsSelectionIndicator = YES;
[actionSheet addSubview:pickerView];
[actionSheet showInView:self.view];
I need "FirstViewController" when MultiPicker finishes, so I can update a table in FirstView. I tried setting a new delegate to MultiPicker so, it tells FirstView when it finishes. But the instruction "multipic.delegate = self" in the first piece of code mades the app crash and says "Terminating due to uncaught exception".
If I simply put all "MultiPicker" code inside FirstViewController class, not in a separate one, the action sheet stay blocked when I try to push a button different from "Cancel"
Any idea?
Thank u
© Stack Overflow or respective owner