Reputation: 4270
I'm trying to use NSURLSession to pull down tweets from the Twitter Streaming API. I wanna try visualizing them in a few ways, maybe using Core Animation or something. But that's besides the point. What I realized about the streaming API is that it… never stops streaming. So any NSURLSessionDataTasks I resume() will just download data forever. Problem is, my completion handler isn't called yet. How do I extract the data from this stream? For the record I'm not aiming to handle all of the tweets, but simply scoop into the stream every few seconds to pull one out.
Upvotes: 2
Views: 311
Reputation: 8079
Implement
func urlSession(_ session: URLSession, dataTask: URLSessionDataTask, didReceive data: Data)
from
URLSessionDataDelegate
That will get called again and again as long as your connection to the streaming API is open.
Upvotes: 1