[英]I am getting an “Implicit conversion from enumeration type” warning in Xcode for iOS and I don't know why
With this code: 使用此代码:
NSDataDetector *detector = [NSDataDetector dataDetectorWithTypes:NSTextCheckingTypeLink
error:&error];
I am getting this warning: 我收到这个警告:
Implicit conversion from enumeration type 'enum NSTextCheckingType' to different enumeration type 'NSTextCheckingTypes' (aka 'enum NSTextCheckingTypes')
Can someone explain to me why I am getting this warning and how to fix it? 有人可以向我解释为什么我会收到此警告以及如何解决此问题?
+dataDetectorWithTypes:
does claim to take a value from the NSTextCheckingTypes enum rather than NSTextCheckingType, but going by the rest of its documentation it should indeed allow you to specify individual values from the latter enum. +dataDetectorWithTypes:
声称从NSTextCheckingTypes枚举而不是NSTextCheckingType中获取值,但是通过其余的文档,它确实允许您从后一个枚举中指定单个值。 I would just add a cast to NSTextCheckingTypes. 我只想添加一个演员到NSTextCheckingTypes。 You might also want to file a bug on the API.
您可能还想在API上提交错误 。
Look at the docs for this method. 查看此方法的文档。 The first parameter needs to be of type
NSTextCheckingTypes
. 第一个参数必须是
NSTextCheckingTypes
类型。 But the value you pass in, NSTextCheckingTypeLink
, is of type NSTextCheckingType
. 但是您传入的值
NSTextCheckingTypeLink
的类型为NSTextCheckingType
。
You need to pass in either NSTextCheckingAllSystemTypes
, NSTextCheckingAllCustomTypes
, or NSTextCheckingAllTypes
. 您需要传入
NSTextCheckingAllSystemTypes
, NSTextCheckingAllCustomTypes
或NSTextCheckingAllTypes
。
Edit: 编辑:
Upon further review, while what I stated seems correct from a parameter point of view, the rest of the docs for the method claim something else that contradicts the parameter type. 在进一步审查时,虽然从参数的角度来看我所说的似乎是正确的,但该方法的其余文档声称其他与参数类型相矛盾的东西。 Either something changed or this is a bug.
无论是改变了什么,这都是一个错误。 Someone should report this to Apple.
有人应该向Apple报告。
Further edit: 进一步编辑:
One workaround would be to make use of a cast: 一种解决方法是使用强制转换:
NSDataDetector *detector =
[NSDataDetector dataDetectorWithTypes:(NSTextCheckingTypes)NSTextCheckingTypeLink
error:&error];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.