开发者

I want to extend the CoreDataBooks example with a UIPickerView

开发者 https://www.devze.com 2023-01-28 04:39 出处:网络
I am trying to add in a third method into the editting view controller in this example; a simple pickerview for a field.Currently, my pickerview has 6 items that I load into it.When I run it, it shows

I am trying to add in a third method into the editting view controller in this example; a simple pickerview for a field. Currently, my pickerview has 6 items that I load into it. When I run it, it shows a '?' for the value on the picker view rather than t开发者_JS百科he word. It does select the right item/row and return it to the calling controller, but it just won't display the text.

I believe that I am not allocating the array properly to the PickerView as it compiles with the following warning:

"Incompatible Objective-C types assigning 'Struct NArrary *', expected 'struct UIPickerView *'"

Here is what I have declared in the .h file:

 UIPickerView *pickerView;
 NSArray *choiceArray;


 @property (nonatomic, retain) IBOutlet UIPickerView *pickerView;
 @property (nonatomic, retain) NSArray *choiceArray;

And in the .m file:

  choiceArray = [[NSArray alloc] initWithObjects:@"Financial",@"One",@"Two",@"three",@"four",@"six", nil];
  pickerView = choiceArray; //<-- error
  [choiceArray release];

It's this line: "pickerView = choiceArray;" that I get the warning on.

thx, wes


You are assigning the array to the pickerView attribute itself. Your are doing this:

(UIPickerView*)pickerView = (NSArray*)choiceArray;

You actually assign the rows of a picker view from its delegate which is an object that implements the UIPickerViewDelegate protocol.

0

精彩评论

暂无评论...
验证码 换一张
取 消