在UIPickerViewDelegate方法的末尾显示警告消息 [英] shows warning msg at the end of the UIPickerViewDelegate method
问题描述
我已经在我的应用程序中创建了一个pickerview,并为它的两个组件创建了一个.h文件代码,如下所示:
I have created a pickerview in my application and create two component of it for that in my .h file code is as follows
@interface tweetViewController : UIViewController<UIPickerViewDataSource ,UIPickerViewDelegate> {
NSArray *activities;
NSArray *feelings;
}
@property(nonatomic,retain) NSArray *activities;
@property(nonatomic,retain) NSArray *feelings;
@end
之后,在我的.m文件中,我已经为UIPickerViewDataSource和UIPickerViewDelegate实现了强制方法,但是UIPickerViewDatasource的两种强制方法都可以正常工作它的代码是
after that in my .m file i have implemented compulsory method for UIPickerViewDataSource and UIPickerViewDelegate but both compulory methods of UIPickerViewDatasource works fine and its code is
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
return [activities count];
}
else
{
return [feelings count];
}
} return 2;
}
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
if (component==0) {
return [activities count];
}
else
{
return [feelings count];
}
}
但是UIPickerViewDelegate的方法在该方法的末尾显示警告
but the method of UIPickerViewDelegate shows warning at the end of the method
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
switch (component) {
case 0:
return [activities objectAtIndex:row];
break;
case 1:
return [feelings objectAtIndex:row];
break;
}
}
告诉我为什么会发生警告??
tell me why does the warning occur????
推荐答案
警告控件可能会到达非void函数的末尾." 的意思是说该方法没有返回任何内容,因为方法有一些返回值.
The warning "control may reach end of non-void function.." means to say that the method is returning nothing as the method is having some return value.
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
NSString *strToReturn = @"";
switch (component) {
case 0:
strToReturn = [activities objectAtIndex:row];
break;
case 1:
strToReturn = [feelings objectAtIndex:row];
break;
}
return strToReturn;
}
按上述方法修改您的代码,警告将不会再惹恼您.
Modify your code as above and the warning will be no more to irritate you.
这篇关于在UIPickerViewDelegate方法的末尾显示警告消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!