开发者社区> 问答> 正文

swift 上传图片到OSS问题

各位大侠,我用swift来上传图片到OSS上,采用pod导入库,一切都好,但是在调用OSSTask的contineWithBlock时,出错:
1. 系统提示已经改名为continue了,我改完后,跳转过去后发现,确实是名字改成这样了,但是查看OSSTask.m,却还是原来的样子,不知道这是什么原因?

   /*!
     Enqueues the given block to be run once this task is complete.
     This method uses a default execution strategy. The block will be
     run on the thread where the previous task completes, unless the
     the stack depth is too deep, in which case it will be run on a
     dispatch queue with default priority.
     @param block The block to be run once this task is complete.
     @param cancellationToken The cancellation token (optional).
     @returns A task that will be completed after block has run.
     If block returns a OSSTask, then the task returned from
     this method will not be completed until that task is completed.
     */
     open func `continue`( _ block: @escaping AliyunOSSiOS. OSSContinuationBlock, cancellationToken: OSSCancellationToken?) -> OSSTask< AnyObject>


    
     /*!
     Enqueues the given block to be run once this task is complete.
     @param executor A OSSExecutor responsible for determining how the
     continuation block will be run.
     @param block The block to be run once this task is complete.
     @returns A task that will be completed after block has run.
     If block returns a OSSTask, then the task returned from
     this method will not be completed until that task is completed.
     */
     open func `continue`(with executor: OSSExecutor, with block: @escaping AliyunOSSiOS. OSSContinuationBlock) -> OSSTask< AnyObject>


    /*!
       A block that can act as a continuation for a task.
    */

    public typealias OSSContinuationBlock = ( OSSTask< ResultType>) -> Any?




2. 一番调研后,我发现OSSTask实际上是来自于开源框架Bolts, 我参照bolts的swift调用方法,改成如下,但是报 Ambiguous reference to member 'continue',



         let putTask = ossClient?. putObject(put)
        putTask. continue {
            
            (task : OSSTask) -> Any in
            
             if (!(task.error != nil)) {
                finished( true, nil)
            } else {
                finished( false,task.error as! String?)
            }
        }


3. 本人对iOS和swift都是新手,哪位大侠帮忙看看原因是什么?

展开
收起
布衣爵士 2016-11-24 16:58:31 8444 0
2 条回答
写回答
取消 提交回答
  • Reswift 上传图片到OSS问题
    sdk不是只有oc版本的,你这个是swift版本的?
    2016-12-04 17:47:39
    赞同 展开评论 打赏
  • Reswift 上传图片到OSS问题
    自己顶一下,看看是否有人帮助一下
    2016-11-25 09:13:08
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
OSS运维进阶实战手册 立即下载
《OSS运维基础实战手册》 立即下载
OSS运维基础实战手册 立即下载