在Apple's doc我无法找到当我想捕获CoreFoundation对象时我能做些什么。是否可以阻止捕获CoreFundation对象?
但在苹果的Concurrency Programming Guide。这似乎示例代码使用一些代码,派遣对象不支持ARC就像这样:
void average_async(int *data, size_t len, dispatch_queue_t queue, void (^block)(int))
{
// Retain the queue provided by the user to make
// sure it does not disappear before the completion
// block can be called.
dispatch_retain(queue);
// Do the work on the default concurrent queue and then
// call the user-provided block with the results.
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
int avg = average(data, len);
dispatch_async(queue, ^{ block(avg);});
// Release the user-provided queue when done
dispatch_release(queue);
});
}
我需要之前,使用CFObject
像DispatchObject
。但是如果我需要多次调用该块?
也许我可以使用__attribute__((NSObject))
,但我不知道会发生什么!
苹果是否对此有所说?
我也有帖子[一个问题](http://stackoverflow.com/questions/26090776/right-way-to-use-attribute-nsobject-with-arc))有关如何使用__attribute __((NSObject ))。当使用这个时,似乎事情变得非常奇怪。 – Karl 2014-09-29 01:13:37