title: obj-c return block NSString to c++ after request
body: <p>I'm trying to get this data correctly back to c++, but there are some random crashes. I want to access the data in C++. Sometimes it does, sometime it doesn't. I couldn't find a clear example on how to return this data.  Here's my code:</p>
  
  <pre><code>- (NSString*) sendRequestToServer : (CLLocationCoordinate2D) location {
    NSLog(@"getting geo from server %@ %@ ", [NSString stringWithFormat:@"%f", location.latitude],[NSString stringWithFormat:@"%f", location.longitude]);
    __block long returnBytesSend = 0;
    __block long returnBytesTotal = 0;
    __block NSString* tempData = @"" ;
    __block BOOL foundNow = false;
    self.data = nil;
  
    for (NXOAuth2Account *account in [[NXOAuth2AccountStore sharedStore] accounts]) {
  
      NSMutableDictionary *params = [NSMutableDictionary dictionary];
  
      [params setObject: [NSString stringWithFormat:@"%f", location.latitude]  forKey:   @"latitude"];
      [params setObject:  [NSString stringWithFormat:@"%f", location.longitude] forKey:@"longitude" ];
      [params setObject: @"10" forKey:   @"radius" ];
      [params setObject: @"5" forKey: @"limit"];
  
      NXOAuth2Client *client =     [account oauthClient];
      NXOAuth2AccessToken *tokenData = [client accessToken];
  
      NSString * clientAccessToken = [tokenData accessToken];
      NSString * clientRefreshToken = [tokenData refreshToken];
  
      if (clientAccessToken &amp;&amp; clientRefreshToken ){
  
          [NXOAuth2Request performMethod:@"GET"
                              onResource:[NSURL URLWithString:@"http://www.server.com/list"]
                         usingParameters: params
                             withAccount:account
                     sendProgressHandler:^(unsigned long long bytesSend, unsigned long long bytesTotal) {
                         returnBytesSend =  bytesSend ;
                         returnBytesTotal = bytesTotal;
                     }
                         responseHandler:^(NSURLResponse *response, NSData *responseData2, NSError *error){
                                    NSLog(@"FOUND DATA");
                              NSRange range = [[[NSString alloc] initWithData:responseData2 encoding:NSUTF8StringEncoding] rangeOfString :  @"facebook_id"];
                             if(range.location != NSNotFound) {
                                  tempData = [[[NSString alloc] initWithData:responseData2 encoding:NSUTF8StringEncoding]retain];
                                 //NSLog(@"%@",  tempData);
                                 self.data = [[tempData copy] autorelease];
                                 foundData = true;
  
                             }
                         }];
      }
  }
  
    return tempData;
  
  }
  </code></pre>
  
  <p>I was trying to acces the data this way:</p>
  
  <pre><code> @interface oAuthView : UIWebView
  @property (nonatomic, strong) __block  NSString* data;
  @property (nonatomic) __block BOOL foundData;
  </code></pre>
  
  <p>and in c++ like this:</p>
  
  <pre><code>    oAuthView *getWebView;
      getWebView =[[oAuthView alloc] initWithFrame:CGRectMake(10,40,300,400)];
      if ([getWebView foundData]  )  
      string dataS = string([[artPartView data] UTF8String]));
  </code></pre>