문제

I'm hoping to convert this 10.6 code to 10.5:

@autoreleasepool {

    dispatch_queue_t queue = dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);

    dispatch_async(queue,^(){

      // contact webservice for IP-address information

      // update UI (NSMenuItem)

    });
}

What I have so far:

NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

  // background process

    // contact webservice for IP-address information

    // update UI (NSMenuItem)

  // end background process

[pool drain];

It appears that a can use dispatch_async, but not blocks and dispatch_queue_t.

도움이 되었습니까?

해결책 2

It really depends on what happens in the // stuff here section.

Essentially, it comes down using a pre-GCD form of concurrency. If you're targeting 10.5, then you also have NSOperation at your disposal.

다른 팁

If you need to support Leopard, you could always go back to old school "NSThread" (<-- documentation linked here), which continues to be fully supported up and through 10.9 & beyond.

Blocks and dispatch_queue_t came in with MacOS 10.6 & iOS 4.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top