ios swift 扩展显示错误

ios swift extension show error

我编写了一个扩展程序来将图像共享到我的网络服务。服务器正在毫无问题地接收项目,但服务器上发生了一些事情,导致执行在预期的状态更改之前终止。

我想弄清楚如何在共享扩展中点击 post 按钮后显示网络服务器的响应(如错误)。

这可能吗?怎么做到的?

我的 didSelectPost:

override func didSelectPost() {   
    let identifier = NSBundle.mainBundle().bundleIdentifier! + "." + NSUUID().UUIDString
    let configuration = NSURLSessionConfiguration.backgroundSessionConfigurationWithIdentifier(identifier)

    configuration.sharedContainerIdentifier = "group.aa.com"

    let session = NSURLSession(configuration: configuration)

    let request = urlRequestWithImage(attachedImage, text: contentText)!

    let task = NSURLSession.sharedSession().dataTaskWithRequest(request)

    task.resume()

    extensionContext?.completeRequestReturningItems([], completionHandler: nil)

}

在 XCode select 应用程序 运行ning 中,它位于 STOP 图标和设备之间 select 或者。从那里选择扩展名和 运行 在模拟器或连接的设备上,现在您将在 XCode

中看到代码中的 printlns