0

我正在尝试将这些数据正确地返回到 C++,但是有一些随机崩溃。我想访问 C++ 中的数据。有时会,有时不会。我找不到有关如何返回此数据的明确示例。这是我的代码:

- (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 && 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;

}

我试图以这种方式访问​​数据:

 @interface oAuthView : UIWebView
@property (nonatomic, strong) __block  NSString* data;
@property (nonatomic) __block BOOL foundData;

在 c++ 中是这样的:

    oAuthView *getWebView;
    getWebView =[[oAuthView alloc] initWithFrame:CGRectMake(10,40,300,400)];
    if ([getWebView foundData]  )  
    string dataS = string([[artPartView data] UTF8String]));
4

0 回答 0