Raj
Raj

Reputation: 537

SKStoreProductViewController initialization on non main thread

I am seeing an occasional crash as I initialize SKStoreProductViewController on non main thread. I don't see any docs about initializing it on main thread. Do we have to initialize SKStoreProductViewController on main thread?

Upvotes: 0

Views: 799

Answers (1)

CodeBender
CodeBender

Reputation: 36670

I just made this as an answer so that it can highlight the point made by rmaddy in the comment.

Important

Use UIKit classes only from your app’s main thread or main dispatch queue, unless otherwise indicated. This restriction particularly applies to classes derived from UIResponder or that involve manipulating your app’s user interface in any way.

https://developer.apple.com/documentation/uikit

And as rmaddy pointed out, the class definition:

open class SKStoreProductViewController : UIViewController

So yes, you need to use the main thread.

Upvotes: 1

Related Questions