Null passed to a callee that requires a non-null argument

时光总嘲笑我的痴心妄想 提交于 2019-12-02 00:30:57

问题


I have been using this to convert a CIImage to NSData for ages:

  NSData *data = [imageRep representationUsingType: NSPNGFileType
                            properties:nil];

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?


回答1:


Is this the correct way to solve this problem?

Yes.

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.



来源:https://stackoverflow.com/questions/34557563/null-passed-to-a-callee-that-requires-a-non-null-argument

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!