SKProductRequest同步

发布于 2024-12-25 17:23:17 字数 693 浏览 0 评论 0原文

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

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 同步

苹果文档今天运气好,能获得有关此主题的更多信息

i start the product request already in a operation block

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

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

      request.delegate = self;

      [request start];

}];

so i would like to use some synchronous version, like when downloading data

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

or parsing XML is also synchronous

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

Is there a way for to do the SKProductsRequest synchronous

The apple documentation luck on further info on this topic at this day

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

终止放荡 2025-01-01 17:23:17

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

// 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];

然后在代表中。

i found a way how to make any method synchronous :

// 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];

Make sure to invoke!!!!!!!!!!!!!!!!!

[self.theLock unlockWithCondition:1];

In the delegate(s) then.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文