Asynchronous vs Synchronous vs Threading in an iPhone App

后端 未结 8 1398
失恋的感觉
失恋的感觉 2021-01-30 05:28

I\'m in the design stage for an app which will utilize a REST web service and sort of have a dilemma in as far as using asynchronous vs synchronous vs threading. Here\'s the sce

8条回答
  •  猫巷女王i
    2021-01-30 06:18

    I don't think that there's a "right" answer. It seems that you understand the compromises involved and you just need to make your design around those.

    A few extra random points: sometimes your application forces a particular approach. For example, many of the convenience (i.e., synchronous) methods won't allow authentication. For me that meant that my decision was made.

    For Yummy I ended up not using threads. I made all my network calls asynchronous and I used the default XML parser (which works using call backs). Since it's all event driven and each unit is small it allows the GUI to be pretty fluid without having the complexity of threading.

    I use a state machine to figure out why I'm getting a particular response, and a queue so that I only need to have a single operation "in flight" at any given time. There's a distinct order to most requests so I have no need for a priority system.

    The networking code is the most complex in my app and it took a long time to get working much less robust!

提交回复
热议问题