SKProductsRequest同步

时间:2012-01-09 13:48:31

标签: cocoa storekit

我已在操作块中启动产品请求

NSOperationQueue * queue = [[NSOperationQueue alloc] init];

[queue addOperationWithBlock:^{
      SKProductsRequest * request= [[SKProductsRequest alloc] initWithProductIdentifiers: selectedSKIdentifiers];

      request.delegate = self;

      [request start];

}];

所以我想使用一些同步版本,比如下载数据时

NSData * data = [[NSData alloc] initWithContentsOfURL:url];

或解析XML也是同步的

NSXMLParser * parser = [[NSXMLParser alloc] initWithData:xmlData];
[parser setDelegate:self];
[parser parse];
[parser release];

有没有办法进行SKProductsRequest同步

苹果文档在这一天有关该主题的进一步信息的运气好运

1 个答案:

答案 0 :(得分:0)

我找到了一种如何使任何方法同步的方法:

// create the object that will perform an async operation
MyConnection *conn = [MyConnection new];

// create the semaphore and lock it once before we start
// the async operation
self.theLock = [NSConditionLock new];

// start the async operation
self.testState = 0;
[conn doItAsyncWithDelegate:self];

// now lock the semaphore - which will block this thread until
// [self.theLock unlockWithCondition:1] gets invoked
[self.theLock lockWhenCondition:1];

// we're done
[self.theLock release];
[conn release];

确保调用!!!!!!!!!!!!!!!!!

[self.theLock unlockWithCondition:1];

然后在代表中。