요청을 보내는 클래스가 많으며 결국 모두 SplitViewController
이됩니다. SplitUIviewclass
에서는 테이블 뷰에서 데이터를 폴링하고 쓰는 시간이 오래 걸립니다. 긴 폴링은 백그라운드 스레드에서 수행됩니다. 따라서 애플 리케이션 델리게이트에서 변수를 선언했습니다.하지만 그럴 때는 nil
입니다. 그리고 문제는 NSMutablearray
에 appdelegate
을 통해 액세스하려고 시도 할 때마다 해당 주소가 nil
이고 배열이 출시 될 때입니다. 롱 폴링에 대한 나의 코드는, 나는 또한 출시되고 수신 된 데이터 또는 변수에 내 응용 프로그램 위임 값을 인쇄 할 수 없습니다, 컨트롤을 잃고, 모든 클래스에서 호에서 변수를 유지하는 방법
- (void) longPoll {
@autoreleasePool
{
//compose the request
NSError* error = nil;
NSURLResponse* response = nil;
NSURL* requestUrl = [NSURL URLWithString:@"http://www.example.com/pollUrl"];
NSURLRequest* request = [NSURLRequest requestWithURL:requestUrl];
//send the request (will block until a response comes back)
NSData* responseData = [NSURLConnection sendSynchronousRequest:request
returningResponse:&response error:&error];
//pass the response on to the handler (can also check for errors here, if you want)
[self performSelectorOnMainThread:@selector(dataReceived:)
withObject:responseData waitUntilDone:YES];
}
//send the next poll request
[self performSelectorInBackground:@selector(longPoll) withObject: nil];
}
- (void) startPoll {
[self performSelectorInBackground:@selector(longPoll) withObject: nil];
}
- (void) dataReceived: (NSData*) theData {
//i write data received here to app delegate table
}
나는 데이터에서 내 SplitView 클래스의 다른 메서드를 호출받은 경우
입니다 내가 여기서 다시로드 테이블이나 다른 방법을 호출 할 수 없습니다.
강점/보유로 재산을 설정하십시오 – codercat
"theData"를 dataRecieved : 방법으로 인쇄 할 수 있습니까? 맞습니까? 그렇다면 더 많은 코드를 게시해야합니다. – Ievgenii
dataRecieved에서 theData를 인쇄 할 수 있으며 확실하게 나에게 시간이 충분하지 않은 게시물 d 전체 문제를 제공 할 수 있습니다. – BackStabber