title: Scheduling socket communication for Swift
body: <p>I am fairly new to Swift programming, please forgive the dummy questions I have got to ask below. </p>
  
  <p>In my app, I am trying to schedule to call a function, which will receive some data from my server and will be called every second. The communication needs to be achieved via a TCP socket. After doing some research, it seems to me that I need to have a way to properly use threads to call that function. So here comes my questions:   </p>
  
  <ol>
  <li>Where should I make the connection to the server? (Should I make the connection in the viewDidLoad() function of my first view controller?)</li>
  <li>Where should I create a thread to schedule the function call? If I create the thread inside my first view controller, would the thread die after I switching to another view controller?</li>
  <li>What QoS level I should use for that thread? The app is rendering the data received from the server every second, so I assume this task would have a very high priority.</li>
  </ol>
  
  <p>I tried looking for tutorials and examples about threads and socket communications, but I could not find information that is applicable to my app. So any help or insight regarding the design would be greatly appreciated!</p>
  
  <p>Thanks in advance!</p>