title: STTwitter - How can i take just 5 record on Stream API
body: <p>I used STTwitter in my project and I want 5 tweet on some coordinates. There is question like this but i dont understand. </p>
  
  <p><a href="https://stackoverflow.com/questions/19859569/how-can-i-stop-a-stream-when-using-sttwitter">How can I stop a stream when using STTWitter</a></p>
  
  <p>I tried like this, but its not stop at 5 records and always return tweet. </p>
  
  <pre><code>-(void)getTwitterActivityWithLocation:(CLLocation *)location withSuccessBlock:(void(^)(NSMutableArray *activities))successBlock
  {
      STTwitterAPI *twitter = [STTwitterAPI twitterAPIOSWithFirstAccount];
      [twitter verifyCredentialsWithSuccessBlock:^(NSString *username) {
          NSString *latRectLeft = [[NSString alloc] initWithFormat:@"%f",location.coordinate.latitude];
          NSMutableArray *data = [[NSMutableArray alloc] init];
  
          id twitterRequest = [twitter postStatusesFilterUserIDs:nil keywordsToTrack:nil locationBoundingBoxes:@[@"28.9986108",@"41.0377369",@"28.9996108",@"41.0387369"] delimited:@20 stallWarnings:nil progressBlock:^(NSDictionary *tweet) {
  
  
              if ([data count] &gt; 4) {
                  [twitterRequest cancel];
                  successBlock(data);
              }
              else if (([[tweet valueForKey:@"geo"] valueForKey:@"coordinates"] != nil)) {
  
                  if (![tweet isEqual:nil] &amp;&amp; [tweet count] &gt; 0)
                  {
                      NSLog(@"%@",[tweet valueForKey:@"text"]);
                      [data addObject:tweet];
                  }
  
              }
  
          } stallWarningBlock:nil
              errorBlock:^(NSError *error) {
                  NSLog(@"Error");
          }];
  
  
      } errorBlock:^(NSError *error) {
          NSLog(@"%@",[error description]);
      }];
  
  
  }
  </code></pre>
  
  <p>If take                 <code>[twitterRequest cancel];</code> line to outside of block, its work. But this time i don't have any tweet record. </p>
  
  <p>How can i solve this ? </p>