1

On iOS (but I think this would be just the same on OSX) I'm using STTWitter.

Among other things, I want to use it to stream the main public timeline.

I've successfully used getStatusesSampleDelimited:stallWarnings:progressBlock:stallWarningBlock:errorBlock: to start streaming tweets.

How can I stop the stream once I've got enough, or want to switch to a different stream (e.g. streaming a search)?

I've tried destroying the STTWitterAPI object - with no effect. I can't see a method on the object to stop streaming, and I've traced the source code through and don't see any way I can stop a stream once it's started.

What have I missed?

Markus Amalthea Magnuson
  • 8,415
  • 4
  • 41
  • 49
rhialto
  • 113
  • 3

1 Answers1

3

The library didn't support cancelling request, so I just added this feature:

id request = [twitter getStatusesSampleDelimited:nil
                                   stallWarnings:nil
                                   progressBlock:^(id response) {
    // ...
} stallWarningBlock:nil
         errorBlock:^(NSError *error) {
    // ...
}];

// ...

[request cancel]; // when you're done with it

After request cancellation, the error block is called once with a cancellation error.

Let me know if it doesn't fulfil your needs.

nst
  • 3,862
  • 1
  • 31
  • 40
  • That looks like it should do exactly what I need. I'll pick it up when the pod spec gets updated. Thanks. – rhialto Nov 09 '13 at 23:20