最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

[已解决]swift中出错:dispatch_release is unavailable

iOS crifan 2176浏览 0评论

参考:

closures – Wait until an asynchronous api call is completed – Swift/IOS – Stack Overflow

去写代码:

        dispatch_semaphore_wait(loginSemaphore, DISPATCH_TIME_FOREVER)

        dispatch_release(loginSemaphore)

结果出错:

dispatch_release  is unavailable

如图:

swift dispatch_release  is unavailable

‘dispatch_release’ is unavailable · Issue #9 · shinobicontrols/iOS8-day-by-day

不存在此函数了?

那有啥替代的函数,还是完全不需要关系,不需要release?

dispatch_release unavailable on ARC? · Issue #204 · ReactiveCocoa/ReactiveCocoa

“I changed the platform to use 5.1 instead of 6.0. Searching for the error message reveals that dispatch_retain and dispatch_release is no longer allowed when targeting iOS 6 (and OS X 10.8 too, apparently, though I have not tested that).”

Coderwall | dispatch_release is no longer needed in iOS 6 with ARC

ios – dispatch_release compiler error when upgrading deployment target – Stack Overflow

“ Compiler does automatically emit code to release dispatch queues and other GCD objects as Objective-C objects. ”

objective c – Does ARC support dispatch queues? – Stack Overflow

[总结]

目前新版本的,iOS 6之后,就不需要用:dispatch_release了。

如果非要用,可以添加编译器参数:

 -DOS_OBJECT_USE_OBJC=0

其他后来的代码:

ios – Wait for async task to finish completion block before returning in app delegate – Stack Overflow

也的确没了dispatch_release

转载请注明:在路上 » [已解决]swift中出错:dispatch_release is unavailable

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
84 queries in 1.058 seconds, using 22.08MB memory