我在 -[NSItemProvider loadItemForTypeIdentifier:options:completionHandler:]
的文档中看到了以下段落:
An extension can specify an expected class for the item’s value in the completion handler block. An error is returned in the completion block’s error parameter if the returned item’s value class doesn’t match the specified class. An item provider can perform simple type conversions for the item specified in the block, such as from NSURL to NSData or NSFileWrapper, or from NSData to UIImage (in iOS) or NSImage (in OS X).
不是说我曾经想要制作一个如此疯狂的 API,但现在我很好奇。运行时 block 类型推断如何工作?
最佳答案
显然这并不新鲜。已经回答了here .
基本上,您可以公开重新声明 block ABI 的私有(private)部分(请参阅 this struct definition )并使用它来创建 NSMethodSignature
(请参阅 this line of code )。
关于ios - Objective-C block 参数类型推断,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27383068/