Objective c 主UI线程中的网络通信
我有以下顾虑 我的应用程序第一次启动时会下载6MB的数据。 在此过程中,会显示Objective c 主UI线程中的网络通信,objective-c,ios,multithreading,networking,Objective C,Ios,Multithreading,Networking,我有以下顾虑 我的应用程序第一次启动时会下载6MB的数据。 在此过程中,会显示UIView,其中包含有关正在进行的下载的信息,并且通常不会与用户进行交互 正因为如此,我使用dispatch\u async在主UI线程中下载所有数据,但现在我不知道这是否是最好的解决方案,也不知道苹果会在我提交应用程序时说些什么 你能告诉我这行不行吗 更新 调度代码 //Called at the end of [UIViewController viewDidLoad] -(void)splashScreenAp
UIView
,其中包含有关正在进行的下载的信息,并且通常不会与用户进行交互
正因为如此,我使用dispatch\u async
在主UI线程中下载所有数据,但现在我不知道这是否是最好的解决方案,也不知道苹果会在我提交应用程序时说些什么
你能告诉我这行不行吗
更新调度代码
//Called at the end of [UIViewController viewDidLoad]
-(void)splashScreenAppeared
{
myTabBarController_.loadingLabel.text = NSLocalizedString(@"Checking for updates",@"launch progress");
dispatch_queue_t d_queue = dispatch_get_main_queue();
[self launchActionCheckIfDataIsStored:d_queue];
}
//...
-(void)launchActionCheckIfDataIsStored:(dispatch_queue_t)queue
{
dispatch_async(queue, ^ {
//If there is no data stored in core data then download xml data files and images
if (![self isAnyDataStoredInCoreData]) {
launchNoDataStored_ = YES;
[self launchDownloadData:queue];
} else {
launchNoDataStored_ = NO;
[self launchCheckNewVersion:queue];
}
});
}
//...
-(void)launchDownloadData:(dispatch_queue_t)queue
{
myTabBarController_.loadingLabel.text = NSLocalizedString(@"Downloading catalog data",@"launch progress");
dispatch_async(queue, ^ {
[self loadMenuData];
if (seriousError_) {
[self launchSeriousError:queue];
return;
}
myTabBarController_.loadingLabel.text = NSLocalizedString(@"Downloading products details",@"launch progress");
dispatch_async(queue, ^ {
[self loadProductsData];
if (seriousError_) {
[self launchSeriousError:queue];
return;
}
//...
//And so on with other parts of download
}
为了设置背景,我已经编写并向应用商店提交了两个成功的应用程序,所以你知道我不是在假设 回到这里,您可以将下载推送到后台线程,并以滑块的形式更新进度(为了用户的利益)。但是,如果在这种情况下,用户无论如何都不能做任何事情,那么就没有意义了
另外,我不认为苹果会因为这个拒绝你的应用。他们检查的主要内容之一是,您是否正在使用任何私有API或更基本的东西,如应用程序崩溃。现在我知道,UI线程中的网络通信可能是苹果拒绝你的应用程序的一个很好的理由 考虑以下场景:
- 该应用程序适用于iPhone
- 没有与用户的交互
- 应用程序在iPad上运行李>
所以UI线程中的网络通信是有效的,但若应用程序不仅适用于iPad,那个么在苹果审查过程中应用程序将被拒绝。谢谢你们的快速回复,但由于某些原因,当我从Xcode运行应用程序时,我的应用程序在启动时崩溃。以前它工作得很好。。呵呵,看来我的应用程序没有正确的配置文件。最近,我将配置文件更改为release,以便将其作为ipa进行测试。Jupi:)发布你的调度代码。