내 응용 프로그램은 특정 URL로 10 초마다 서버에서 요청을 보내고 URL의 일부 속성을 변경 한 다음 요청을 "updateView"라는 다른보기 또는 다른 네트워크 오류가 발생하여 오류가 표시됩니다. 첫 번째 부분은 잘 작동하지만 Wi-Fi로 전환하면 앱이 다운됩니다. 어떻게이 문제를 해결하고 다양한 오류를 표시합니까? 미리 감사드립니다 !! 현재 당신이 stringWithContentsOfURL를 사용하는NSURL 오류 처리
+ (id)stringWithContentsOfURL:(NSURL
*)url encoding:(NSStringEncoding)enc error:(NSError **)error
에
전화를 1.Changing :
- (void)serverUpdate{
CLLocationCoordinate2D newCoords = self.location.coordinate;
gpsUrl = [NSURL URLWithString:[NSString stringWithFormat:@"http://odgps.de/chris/navextest?objectid=3&latitude=%2.4fN&longitude=%2.4fE&heading=61.56&velocity=5.21&altitude=%f&message=Eisberg+voraus%21", newCoords.latitude, newCoords.longitude, self.location.altitude]];
self.pageData = [NSString stringWithContentsOfURL:gpsUrl];
[updateView.transmissions insertObject:pageData atIndex:counter];
if (counter == 100) {
[updateView.transmissions removeAllObjects];
counter = -1;
}
counter = counter + 1;
[updateView.tableView reloadData];
self.sendToServerSuccessful = self.sendToServerSuccessful + 1;
[self.tableView reloadData];
}
큰 난이 대단히 감사합니다 많은 도움이 될 것 같아요! 하지만 내가 상태 코드를 표시 할 수 있기 때문에 이전에 설정 한 속성을 가진 URL (요청 URL)을 표시하고 싶다면 어떻게해야합니까? –
그리고 어떤 유형이 "statusCode"변수입니까? –
statusCode는 int입니다. 요청을 표시하려면 응답 형식에 따라 다르지만 UIWebView가 가장 잘 작동합니다. – lucius