I use pickerview in my application and in .h file i have written code as follows
@interface t开发者_StackOverflow中文版weetViewController : UIViewController<UIPickerViewDataSource,UIPickerViewDelegate> {
    NSArray* activities;
    NSArray* feelings;
}
@property (nonatomic,retain) NSArray *activities;
@property (nonatomic,retain)NSArray *fellings;
and i have written code in my.h file for UIPickerviewDatasource as follows which works fine
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
    return 2;
}
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
    if(component==0)
    {
        return [activities count];
    }
    else
    {
        return [feelings count];
    }
}
but the following code of UIPickerViewDelegate shows me warning msg at the closing brace of the method
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
    switch (component) {
        case 0:
            return [activities objectAtIndex:row];
        case 1:
            return [feelings objectAtIndex:row];
    }
}
plz suggest me how i can solve the problem...
This is because the compiler is not sure you're going to return something.
Your method does the following:
if case == 0: return [activities objectAtIndex:row];
if case == 1: return [activities objectAtIndex:row];
In praxis, this will always return a value. However, the compiler checks your code fully theoretically and finds out that if case would be any other integer than 0 and 1, your method doesn't return.
Bottom line is that you need to add return nil; after your switch-block =), so your method will always return (nil will be interpreted as @"" in this case).
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论