Null传递给需要非null参数的被调用方 [英] Null passed to a callee that requires a non-null argument
问题描述
我一直在使用它来将CIImage转换为NSData很久了:
I have been using this to convert a CIImage to NSData for ages:
NSData *data = [imageRep representationUsingType: NSPNGFileType
properties:nil];
现在在Capitan上,第二行出现此错误:
Now on El Capitan I have this error on the second line:
Null passed to a callee that requires a non-null argument
我可以通过在属性上使用空数组来解决此问题,如下所示:
I can solve that by using an empty array on the properties, like this:
NSData *data = [imageRep representationUsingType: NSPNGFileType
properties: @{}];
但是我怀疑这将来会给我带来麻烦.
but I am suspecting that this can cause me problems in the future.
这是解决此问题的正确方法吗?
Is this the correct way to solve this problem?
推荐答案
这是解决此问题的正确方法吗?
Is this the correct way to solve this problem?
是的
在API中似乎有一些地方接受了nil
值,而不是一个空集合,即使它没有被证明是有效的. Apple为更好地支持与Swift的互操作而添加的non-nil注释只是突出显示了这些.
There appear to be a few places in the API which accepted nil
values rather than an empty collection even though it was not documented as valid. The non-nil annotations added by Apple to better support inter-working with Swift are just highlighting these.
这篇关于Null传递给需要非null参数的被调用方的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!