我已經返回的NSData .I以下API方法都調用此方法中另一個視圖控制器。我要轉換的NSData的到NSInteger的。如何是這可能。如何NSData的變量轉換成NSInteger的變量在iphone
-(NSData *)getBusXMLAtStop:(NSString*)stopnumber
{
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:
[NSURL URLWithString: [NSString stringWithFormat:@"http://www.google.com/ig/api?weather=,,,50500000,30500000",stopnumber]]];
[request setHTTPMethod: @"GET"];
dataReply = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
NSLog(@"%@",dataReply);
return dataReply;
}
-(void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
api *ap = [[api alloc]init];
NSData *str = [ap getBusXMLAtStop:@"1"];
// Here is where I want to convert str into NSInteger type. How is this possible?
NSLog(@"this is success %@",ap.dataReply);
TWeatherParser *parser = [[TWeatherParser alloc]init];
[parser getInitialiseWithData:ap.dataReply];
[parser release];
[ap release];
}
我想轉換RO整數 – Rocky 2011-05-25 10:35:58
@Rocky我更新了我的答案。 – Anton 2011-05-25 10:46:30
但方法是返回NSData,所以我懷疑它是否不會創建任何問題,當我將它直接轉換爲nsstring變量。感謝 – Rocky 2011-05-25 10:51:22