我想NSURLConnection 在后台模式下做,因为它的响应有很多数据.论坛要求使用Apple的有限长度编码didEnterBackground.但我想避免使用我通过下面的代码它.相反NSOperation有NSInvocation作为,但它不工作.connectToServer有NSURLConnection操作.请帮忙吗?didReceiveData,didReceiveResponse委托方法不调用?
NSOperationQueue *queue = [NSOperationQueue new];
NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithTarget:self
selector:@selector(connectToServer)
object:nil];
[queue addOperation:operation];
[operation release];
[queue autorelease];
-(void)connectToServer
{
NSURL *url = [NSURL URLWithString:@"http://www.google.com"];
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
NSURLConnection *theConnection = [[[NSURLConnection alloc] initWithRequest:theRequest delegate:self] autorelease];
if( theConnection )
{
webData = [[NSMutableData data] retain];
}
else
{
NSLog(@"theConnection is NULL");
}
}
Run Code Online (Sandbox Code Playgroud) 我在创建xcode项目时选择了本地git repositary.但是当导入到SVN并提交时,它在本地提交而不是在SVN中提交.我该如何解决这个问题?我想从Xcode项目中删除所有隐藏的本地git文件而不影响源代码?有什么帮助吗?
我们怎样才能在NSXmlparser中处理自动关闭标签?没有起始元素和结束元素 - 是否可以处理以下类型的标记?
<ITEM NAME/>
<REG Number/>
Run Code Online (Sandbox Code Playgroud) 我在一个单独的viewcontroller中从ASynchronous NSURLConnection下载大数据.下载数据需要2分钟.它工作正常.但是当我通过退出应用程序进入后台模式并再次打开时,启动画面会强制关闭应用程序.当下载小数据时,它在后台模式下在同一个视图控制器中工作正常.我在读取苹果的有限长度后使用了以下代码documnet.但它没有用?请帮忙吗?
- (void)applicationDidEnterBackground:(UIApplication *)application
{
UIApplication *app = [UIApplication sharedApplication];
bgTask = [app beginBackgroundTaskWithExpirationHandler:^{
[app endBackgroundTask:bgTask];
bgTask = UIBackgroundTaskInvalid;
}];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{});
[app endBackgroundTask:bgTask]; bgTask = UIBackgroundTaskInvalid;
}
Run Code Online (Sandbox Code Playgroud) ios ×3
ios4 ×2
ipad ×2
iphone ×2
android ×1
git ×1
git-svn ×1
nsinvocation ×1
nsoperation ×1
objective-c ×1
xcode ×1
xcode4.2 ×1
xml ×1