Basic Multithreading and queue strategy

I have a few ViewController that do UI thing for setting up the App and preference but then all my app do is receive data from bluetooth and display it


From what I understand, most of what I do could be donne in another queue, off the main queue

i have viewless objects for those task

My BluetoothManager - get data from bluetooth and format it in an array once i have a whole line of data

My DataPreparation - get data from bluetoothManager, do some calculation and enter it in core data

My FileManager - every few lignes received, log it into a file the data the user ask for in pref.


Once DataPreparation has calculated everything, it send the data to an UIViewCollection to display it

In my collection view, I only update the visible cell because i receive data every second and I am trying to minimise the load here


Yet, sometime, when I scroll, I feel the UI is frozen, not long but I don't like it.


I am currently looking at doing the writing to file with DispatchQoS.background or maybe DispatchQoS.userInitiated


But :-)


is there away to dispatch more work or even a whole object into another thread.

Replies

Yet, sometime, when I scroll, I feel the UI is frozen, not long but I don't like it.

In situations like this it’s best to profile (in Instruments) your app so that you understand the cause of these stutters before you start shuffling code around. For example, this:

I am currently looking at doing the writing to file with

DispatchQoS.background
or maybe
DispatchQoS.userInitiated

may or may not help depending on whether the file operations are a significant contributor to these delays.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"