
“Unexpected value class.”
.如果我尝试将其加载为ID< NSSecureCoding> item和deBUG,我发现传入的对象确实只是页面的标题而不是URL.我如何阅读URL?
NSURL *pageURL = nil; for (NSExtensionItem *item in self.extensionContext.inputItems) { for (NSItemProvIDer *itemProvIDer in item.attachments) { if ([itemProvIDer hasItemConformingToTypeIDentifIEr: (Nsstring*) kUTTypeURL]) { [itemProvIDer loadItemForTypeIDentifIEr:(Nsstring*) kUTTypeURL options:nil completionHandler:^(ID <NSSecureCoding> urlitem,NSError *error) { if ([((NSObject*)urlitem) isKindOfClass: [NSURL class]]) { pageURL = [((NSURL*)urlitem) absoluteString]; } }]; } } }解决方法 如果您阅读以下文档: loadItemForTypeIDentifIEr(_:options:completionHandler:)
你会看到:
The type information for the first parameter of your completionHandler
block should be set to the class of the expected type. For example,
when requesting text data,you might set the type of the first
parameter to Nsstring or NSAttributedString. An item provIDer can
perform simple type conversions of the data to the class you specify,
such as from NSURL to NSData or NSfileWrapper,or from NSData to
UIImage (in iOS) or NSImage (in OS X). If the data Could not be
retrIEved or coerced to the specifIEd class,an error is passed to the
completion block’s.
也许你可以通过胁迫不同的类型进行实验?
总结以上是内存溢出为你收集整理的ios – Share extension loadItemForTypeIdentifier返回NSURL的错误全部内容,希望文章能够帮你解决ios – Share extension loadItemForTypeIdentifier返回NSURL的错误所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)