EXC_BAD_INSTRUCTION happens when using dispatch_get_global_queue on ios 7(swift)

前端 未结 2 1675
小蘑菇
小蘑菇 2021-01-18 07:07
    let downloadGroup = dispatch_group_create()
    var images = [UIImage]()
    var errors = [NSError]()
    dispatch_apply(UInt(urls.count), dispatch_get_global_qu         


        
相关标签:
2条回答
  • 2021-01-18 07:26

    found out the reason seconds after i posted. it seems not me being stupid, but apple's document

    QOS_CLASS_USER_INTERACTIVE, QOS_CLASS_USER_INITIATED, QOS_CLASS_UTILITY, or QOS_CLASS_BACKGROUND
    

    can not be used on ios7, though https://developer.apple.com/library/ios/documentation/Performance/Reference/GCD_libdispatch_Ref/#//apple_ref/c/func/dispatch_get_global_queue
    doesn't bother to metion any of it instead use

    DISPATCH_QUEUE_PRIORITY_HIGH, DISPATCH_QUEUE_PRIORITY_DEFAULT, DISPATCH_QUEUE_PRIORITY_LOW, DISPATCH_QUEUE_PRIORITY_BACKGROUND
    
    0 讨论(0)
  • 2021-01-18 07:49

    In my view, your main question is not global queue,is this method dispatch_get_main_queue. Please check it on API Documentation. It's used in iOS 8.0+ only, I choose to use - (void)performSelectorOnMainThread:(SEL)aSelector withObject:(id)arg waitUntilDone:(BOOL)wait instead.

    0 讨论(0)
提交回复
热议问题