NSURLConnection
요청을 보내면 문제가 없습니다. 이제 정보를 새로 고침 (예 : NSURLConnection.Refresh
) 버튼의 IBAction에서 호출 할 때 다시 작동하고 싶습니다. 그러나 NSThread
방법에서 작동하지 않습니다. 이 문제를 해결하는 방법. 여기 NSThread
은 시스템 시간을 실행하는 기능입니다. 시간이 오전 1시와 같을 때 API를 새로 고칩니다. 그러나 대표자는 NSURLConnection
으로 전화하지 않습니다. NSThread 함수에서 호출 할 때 NSURLConnection 대리자가 호출되지 않습니다.
이
가있는 NSURLConnection 코드 : 코드 위-(void)displays:(model *)place
{
NSString *strs=[@"http://www.earthtools.org/timezone-1.1/" stringByAppendingString:[NSString stringWithFormat:@"%@/%@",place.latitude,place.longitude]];
NSMutableURLRequest *request=[NSMutableURLRequest requestWithURL:[NSURL URLWithString:strs]];
NSURLConnection *reqTimeZone=[NSURLConnection connectionWithRequest:request delegate:self];
[reqTimeZone start]; //here request not get start
}
가 호출 된 함수에서 함께 "에"인수는 모든 장소의 세부 사항을이 클래스의 인스턴스입니다.
NSthread 기능 코드 : 표시 기능 위
- (void) setTimer {
//assign current time
[self countDown];
}
- (void) countDown {
//count the current time
if(hrs==12&& [email protected]"pm")
[self display:(placedetails)];//it calls the displays function but NSURLConnection is not get start.
[NSThread detachNewThreadSelector:@selector(setTimer) toTarget:self withObject:nil];
}
할당 placedetails라고하지만 NSURLConnection
대표가 호출되지 않습니다.
은 내가 하루 종일 보냈다 ... 나에게 도움을 주시기 바랍니다 : 여기에
은 예입니다. 버튼 기능 API 호출에서 작동합니다. 그러나 NSThread에서 작동하지 않습니다. – Madhubalan대리자 메서드를 호출하려면 runloop를 NSURLConnection에 연결해야합니다. 스레드를 만들고 NSURLConnection을 스레드의 RunLoop에 연결하지 않으므로 연결 대리자 메서드가 실행되지 않습니다. – 0x8badf00d