nst / STTwitter

A stable, mature and comprehensive Objective-C library for Twitter REST API 1.1
BSD 3-Clause "New" or "Revised" License
999 stars 165 forks source link

getStatusesSampleStallWarnings:... Not consistently posting back progressBlock #253

Closed mrabenhorst closed 8 years ago

mrabenhorst commented 8 years ago

Using this very basic implementation I was unable to reliably obtain progressBlock callbacks.

STTwitterAPI *twitter = [STTwitterAPI twitterAPIWithOAuthConsumerKey:@"..."
                                                          consumerSecret:@"..."
                                                              oauthToken:@"..."
                                                        oauthTokenSecret:@"..."];

_request = [twitter getStatusesSampleStallWarnings:[NSNumber numberWithInt:0] progressBlock:^(NSDictionary *json, STTwitterStreamJSONType type) {
       // ... code here was not run even though the network had traffic ... //
} errorBlock:^(NSError *error){
        NSLog(@"Error: %@", error);
}];

I traced back the problem to the implementation of getStatusesSampleStallWarnings:..., line # 1463. streamParser was becoming nil seemingly at random. I fixed the bug by referencing self.streamParser for both the test and successive parseWithStreamData:... call.

I am not sure if that is an elegant way to fix it, but it is a workaround for now.