出现警告:incompatible pointer types returning from a function with result type

出现警告:incompatible pointer types returning from a function with result type的解决办法

 - (UIViewController *)masterViewController
{
if (_viewControllers && [_viewControllers count] > 0) {
NSObject *controller = [_viewControllers objectAtIndex:0];
if ([controller isKindOfClass:[UIViewController class]]) {
return [(id)[controller retain] autorelease];
}
}
return nil;
}




出现这个问题时因为返回值不匹配,这里为了不改变过多代码,这里添加一个(id)会消除警告



   

你可能感兴趣的:(function,Class,returning,Types)