参考:
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
其他后来的代码:
也的确没了dispatch_release