草庐IT

multiple-dispatch

全部标签

swift - 错误 : Multiple commands produce . .. x86_64.swiftmodule

我正在将一个旧应用程序从swift3迁移到swift4,但遇到了这个错误:error:Multiplecommandsproduce'/Users/.../Library/Developer/Xcode/DerivedData/.../Debug-iphonesimulator/CompassV3.swiftmodule/x86_64.swiftmodule':1)Target'CompassV3'(project'VoidNavigator'):Ditto/Users/.../Library/Developer/Xcode/DerivedData/.../Debug-iphonesi

arrays - 数组在 dispatch_barrier_sync 上损坏

我有2个将数据附加到数组的函数和一个处理它的函数。我使用dispatch_barrier_sync来防止其他函数在我处理数据时更改数据。内部追加函数:autoreleasepool{dispatch_barrier_sync(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,0)){[weakself]()->Voidinself?.bufferVector_.append(data)}}内部流程函数:autoreleasepool{dispatch_barrier_sync(dispatch_get_global_qu

swift - 将 Swift 类标记为 final 是否也会使所有包含的 var、let 和函数自动获得 Static Dispatch 的好处?

我正试图从我的应用程序中榨取最后一点性能。我尝试尽可能在类上使用Structs(没有状态共享,默认情况下直接分派(dispatch)等等)。但是我的ViewController和UIView对象显然仍然是类。出于性能原因,我想对我的每一个方法和数据成员强制执行直接调度。我是否还需要在我的类(class)中标记每个var、let和funcfinal,或者是是否足以将托管类标记为最终类,以便其下的所有内容都可以利用直接方法分派(dispatch)?换句话说:在每个方法和变量之前都粘贴final非常乏味。所以我希望将它放在类(class)本身上具有强制直接dispatch所有类(class)

swift - iOS : A specific function can be called from multiple threads/places, 但我希望每次调用都在队列中执行

我有一个函数readData从HealthKit读取数据,需要几秒钟才能执行。可以从多个线程/位置调用此函数,但我希望每次调用都在一个队列中执行,一次一个,而不是并行执行。有没有一种简单的方法可以使用GCD或OperationQueues在SwiftforiOS中实现这一点? 最佳答案 是的,串行DispatchQueue应该可以解决您的问题。确保您在需要访问它的每个函数都可以访问它的范围内创建它。letserialQueue=DispatchQueue(label:"serialQueue")serialQueue.async{/

multithreading - Swift dispatch_after throwing is not a prefix unary operator 错误

我有以下代码:importSpriteKitimportFoundationclassGameScene:SKScene{varoccupiedCoordinates:NSMutableArray=NSMutableArray()funcaddShape(){//...shape.position=CGPoint(x:actualX,y:actualY)self.occupiedCoordinates.addObject(NSValue(CGPoint:shape.position))lethalfDuration=random(min:CGFloat(0.5),max:CGFloat

ios - Swift:我可以加减 `dispatch_time_t` 变量吗?

我需要在iOS中使用Swift做一些时间计算。我必须使用dispatch_walltime。我希望这可以被视为公理化。在涉及时间数学的地方,我想我可能会得到“只需使用NSDate”的响应,但请相信它:我必须遵守dispatch_walltime。现在,很明显为什么有人会建议使用NSDate,因为当您使用NSTimeInterval和NSDate以及那些好东西时,它非常棒轻松制作自定义时间戳并比较它们并进行各种时间数学计算。但我必须使用dispatch_time_t,特别是像这样创建的dispatch_walltime://GetthetimeIntervalofnow.letnowIn

swift - dispatch_async 与 dispatch_sync 在获取数据中的对比。 swift

看了那么多并行和并发的帖子,我还是很迷惑什么才是正确的取数据方式。例如,在我的项目中,我有一个供用户获取数据的按钮。我的代码如下所示。vararray=[Int]()funcfetchData(){........response(objects:[object],error:NSError?){forobjectinobjects{array.append(object.number)//assumeobject.numberreturnanInt}//confusehere.ShouldIuseasyncherebecauseIamworryiftheuser//clickthef

ReactNative进阶(三十四):Jenkins 流水线 组包 iOS 应用包 ipa Archive 阶段报错error: Multiple commands produce问题修复及思考

文章目录一、前言二、问题描述三、问题解决四、拓展阅读4.1版本号查看4.2ipa包生成过程一、前言在应用RN开发跨平台APP阶段,从git中拉取项目,应用Jenkins进行组包时,发现最终生成的ipa安装包版本号始终与项目中设置的版本号不一致。二、问题描述经过仔细排查,发现Jenkins在Archive编译、归档阶段失败,但是后续Export阶段生成了ipa包。error:Multiplecommandsproduce'/Users/xxx/Library/Developer/Xcode/DerivedData/xxx-eomylkmdzkgaughihoblturddotc/Build/Pr

ios - ViewController 在等待分派(dispatch)信号量时作为弹出窗口

我在发出URLJSON请求时使用DispatchSemaphore进行等待,这种等待可能需要一段时间。为了克服这种情况,我决定制作一个新View,并在发出请求时将其显示为弹出窗口。为此,我使用了以下代码:functableView(_tableView:UITableView,didSelectRowAtindexPath:IndexPath){self.showPopUp()letsemaphore=DispatchSemaphore(value:0)self.api.requestMedicationsByReagent(method:1,ean:"",hash:medHash!,

swift - dispatch_queue_t! 有什么区别?和 dispatch_queue_t?

header显示dispatch_get_global_queue返回globalqueue或NULL。*@result*ReturnstherequestedglobalqueueorNULLiftherequestedglobalqueue*doesnotexist.*/@available(OSX10.6,*)@warn_unused_resultpublicfuncdispatch_get_global_queue(identifier:Int,_flags:UInt)->dispatch_queue_t!为什么返回值是dispatch_queue_t!而不是可选的dispat