gpt4 book ai didi

iphone - 如何在iPhone后台调用JSON webservice

转载 作者:行者123 更新时间:2023-12-03 21:06:29 28 4
gpt4 key购买 nike

我需要知道是否可以从后台调用 json webservices,当用户按下主页按钮时,我从后台执行调用此方法

- (void) runTimer 
{
[NSThread detachNewThreadSelector:@selector(updateAllVisibleElements)toTarget:self withObject:nil];
}

- (void) updateAllVisibleElements {

NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
if(service == nil)
{
service = [[WebService alloc] init];
}
[service getlocationID:currentLatitude andlongitude:currentLongitute];
[pool release];
}

并且调用了函数[service getlocation id],但是之后它没有显示任何响应或数据接收并且应用程序终止,请帮助我

最佳答案

如果您希望应用程序进入后台后立即发生,您可以使用 -[UIApplication beginBackgroundTaskWithExpirationHandler:] 。只要任务不会花费太长时间,这应该可行。

关于iphone - 如何在iPhone后台调用JSON webservice,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6665192/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com