swift - My Action Extension for iOS Not Showing Public.URL in the Debugger -
hi viewer have problem action extension ios i'm trying public url safari has opened can't tell if have public url since not showing in debugger. matter of fact debugger black , information shows if action extension gets interrupted/ crashes.
heres code gets public.url safari.
//get itemprovider wraps url need var item : nsextensionitem = self.extensioncontext!.inputitems[0] as! nsextensionitem var itemprovider : nsitemprovider = extensionitem.attachments?.first as! nsitemprovider //pull url out if (itemprovider.hasitemconformingtotypeidentifier("public.url")) { itemprovider.loaditemfortypeidentifier("public.url", options: nil, completionhandler: { (urlitem, error) in let url : nsurl = urlitem as! nsurl //do need now, such send request server url println(url.absolutestring!); }) }
is there better way of doing written in swift , plus i've around , couldn't find better solution i'm asking there tutorial or example can follow.
i believe following work:
let item : nsextensionitem = self.extensioncontext!.inputitems[0] as! nsextensionitem let itemprovider : nsitemprovider = item.attachments?.first as! nsitemprovider //pull url out if (itemprovider.hasitemconformingtotypeidentifier("public.url")) { itemprovider.loaditemfortypeidentifier("public.url", options: nil, completionhandler: { (urlitem, error) in let url : nsurl = urlitem as! nsurl //do need now, such send request server url print(url.absolutestring); }) }
Comments
Post a Comment