出现警告: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)会消除警告




版权声明:本文为theonezh原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。