I'm trying to gain an advanced understanding of .dataSource. All the examples I see, set it to self. Yet I read that it's a design pattern and can be changed to alter the behavior of the view.
Example:
I've been woking on creating an instance during runtime that will have it's own unique set of methods like
I was told that the key to doing this is in using the UIPickerViewDataSource protocol.
If so, I guess that means that I need to use a different .dataSource other than self. However, all the example I'm finding, use .dataSource = self;.
Q. Does anyone have a link to an example of using a different dataSource other than self and what effect it has?
I'm guessing the protocol is the format to use (methods that need to be addressed) but I see no examples of this.
I'm also thinking of using a block and passing the block into the method and running the block inside of the method.
I suppose another option would be to have a block as a var in a subclass and then access the block thru the class, but I'd still like to see some example of a dataSource other than self and what change it could make.
Thanks.
Example:
Code:
UIPickerView *myPickerView = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 200, 320, 200)];
myPickerView.delegate = self;
myPickerView.dataSource = self;
myPickerView.showsSelectionIndicator = YES;
[self.view addSubview:myPickerView];
I've been woking on creating an instance during runtime that will have it's own unique set of methods like
Code:
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component {
I was told that the key to doing this is in using the UIPickerViewDataSource protocol.
If so, I guess that means that I need to use a different .dataSource other than self. However, all the example I'm finding, use .dataSource = self;.
Q. Does anyone have a link to an example of using a different dataSource other than self and what effect it has?
I'm guessing the protocol is the format to use (methods that need to be addressed) but I see no examples of this.
I'm also thinking of using a block and passing the block into the method and running the block inside of the method.
I suppose another option would be to have a block as a var in a subclass and then access the block thru the class, but I'd still like to see some example of a dataSource other than self and what change it could make.
Thanks.