NSURLConnection
要求が正常に送信されました。今すぐ情報を更新する、つまり、ボタンのIBActionからの呼び出し時にNSURLConnection.Refresh
を再送信したいです。しかし、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
}
はあるが、それはすべての場所の詳細情報を持つクラスの1つのインスタンスです。
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呼び出しが機能します。関数 – Madhubalan
と呼ばれるNSThreadでは動作しません。デリゲートメソッドを呼び出すには、runloopをNSURLConnectionに接続する必要があります。スレッドを作成していて、スレッドのRunLoopにNSURLConnectionを付加していないので、接続代理メソッドは起動しません。 – 0x8badf00d