当我的应用程序处于iOS4.0的后台时,我在启动AudioQueue时遇到困难.当应用程序处于活动状态时,代码工作正常,但在后台运行时代码失败,但代码失败.
err = AudioQueueStart( queueObject, NULL );
if( err )
{
NSLog(@"AudioQueueStart failed with %d", err);
= NO;
AudioQueueStop(queueObject, YES);
return;
}
Run Code Online (Sandbox Code Playgroud)
对于上面的代码,err设置为-12985
我正在加载UIWebview并请求可能需要一些时间才能完成加载的URL.请求开始并开始接收数据.但是,请求似乎没有完成.webViewDidFinishLoad永远不会触发webView didFailLoadWithError:callback.
NSURLRequest的超时是否仅在没有响应接收数据时发生,或者如果请求在该时间间隔内没有完成则触发吗?
如果它是前者,是否有一个优雅的解决方案来超时请求?
相关代码是:
加载请求:
- (void) loadRequest {
NSString *targetURL = @"http://myrequestUrl/";
NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] initWithURL: [NSURL URLWithString: targetURL] cachePolicy: NSURLRequestReloadIgnoringLocalCacheData timeoutInterval: 15.0] autorelease];
[request setHTTPBasicID: [[self credentialManager] userID] password:[[self credentialManager] password]];
[webView loadRequest:request];
Run Code Online (Sandbox Code Playgroud)
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible: NO];
[alert hide];
[alert autorelease];
alert = nil;
NSLog(@"error - %@", error);
[self showRetryPrompt: error];
}
- (void) loadRequest {
NSString *targetURL = @"http://myrequestUrl/";
NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] …