多年来我一直用它来将 CIImage 转换为 NSData:
NSData *data = [imageRep representationUsingType: NSPNGFileType
properties:nil];
现在在 El Capitan 上,我在第二行遇到此错误:
Null passed to a callee that requires a non-null argument
我可以通过在属性上使用空数组来解决这个问题,如下所示:
NSData *data = [imageRep representationUsingType: NSPNGFileType
properties: @{}];
但我怀疑这会在将来给我带来问题。
这是解决这个问题的正确方法吗?
最佳答案
Is this the correct way to solve this problem?
是的。
API 中似乎有一些地方接受 nil
值而不是空集合,即使它没有被记录为有效。 Apple 为了更好地支持与 Swift 的交互而添加的非零注释只是强调了这些。
关于macos - Null 传递给需要非空参数的被调用者,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34557563/