1.

What is the difference between the consumable and non-consumable type of in-app purchase?

Answer»

First, it will PRINT “Apple”.

Next logic is contained in a 'main' async EVENT. So it's postponed. The next thing it will print is "Apple TV". Once the main thread is FREE, our first main.async task will run. So “iPod” will print.

Next to its main.async task again. For this to EXECUTE, the main thread needs free. Since we're still in the middle of the control flow, It will MOVE to DispatchQueue.global().sync.

Read carefully, that it's dispatching sync not async. That means that the main thread is frozen until the code dispatched to the global queue is done.Then it will print “Apple Watch”. So finally prints “iPhone”.



Discussion

No Comment Found

Related InterviewSolutions