gpt4 book ai didi

swift - 在 ios 7(swift) 上使用dispatch_get_global_queue时会发生EXC_BAD_INSTRUCTION

转载 作者:行者123 更新时间:2023-11-30 13:15:19 26 4
gpt4 key购买 nike

    let downloadGroup = dispatch_group_create()
var images = [UIImage]()
var errors = [NSError]()
dispatch_apply(UInt(urls.count), dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0)) { (i) in
dispatch_group_enter(downloadGroup)
SimpleCache.sharedInstance.getImage(urls[Int(i)], completion: { (image, error) -> () in
if let fullImage = image {
images.append(fullImage)
} else {
if let err = error {
DLog(err.description)
errors.append(err)
}
}
dispatch_group_leave(downloadGroup);
})
}
dispatch_group_notify(downloadGroup, dispatch_get_main_queue()) {
completion(images, errors)
}

上面是我的代码
在 ios8 上运行良好
但在ios7上就崩溃了。以下是崩溃日志

...
Code Type: X86-64 (Native)
Parent Process: launchd_sim [16908]
Responsible: launchd_sim [16908]
User ID: 501

Date/Time: 2015-02-19 11:31:34.346 +0900
OS Version: Mac OS X 10.10.2 (14C109)
Report Version: 11
Anonymous UUID: C7FFC618-06B4-6AF8-3BCA-52E19DB5FF20

Sleep/Wake UUID: 5D2D4733-5669-4BBF-BE45-076C93211522

Time Awake Since Boot: 21000 seconds
Time Since Wake: 5400 seconds

Crashed Thread: 0 Dispatch queue: com.apple.main-thread

Exception Type: EXC_BAD_INSTRUCTION (SIGILL)
Exception Codes: 0x0000000000000001, 0x0000000000000000

Application Specific Information:
CoreSimulator 110.4 - Device: iPhone 5s - Runtime: iOS 7.1 (11D167) - DeviceType: iPhone 5s


Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libswiftDispatch.dylib 0x0000000112cceaea _TF8Dispatch25dispatch_get_global_queueFTVSC11qos_class_tSu_CSo8NSObject + 26
...

请帮忙,我确实用谷歌搜索了很多,但没有发现任何有用的东西。dispatch_get_global_queue 不可能在 ios7 上工作,所以一定是我犯了一些愚蠢的错误。只是不做什么

顺便说一句我在用Mac OS X 10.10.2xcode6.1.1

最佳答案

在我发布后几秒钟就找到了原因。看来不是我傻,而是苹果的文档

QOS_CLASS_USER_INTERACTIVE, QOS_CLASS_USER_INITIATED, QOS_CLASS_UTILITY, or QOS_CLASS_BACKGROUND

但不能在ios7上使用 https://developer.apple.com/library/ios/documentation/Performance/Reference/GCD_libdispatch_Ref/#//apple_ref/c/func/dispatch_get_global_queue
懒得提及任何一个而是使用

DISPATCH_QUEUE_PRIORITY_HIGH, DISPATCH_QUEUE_PRIORITY_DEFAULT, DISPATCH_QUEUE_PRIORITY_LOW, DISPATCH_QUEUE_PRIORITY_BACKGROUND

关于swift - 在 ios 7(swift) 上使用dispatch_get_global_queue时会发生EXC_BAD_INSTRUCTION,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38294386/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com