每当遇到连接问题,在2G等连接速度慢,我的应用程序崩溃,并显示以下日志:应用程序崩溃的互联网连接速度较慢
我可以从日志中得到的是,它的sendSynchronousRequest
方法崩溃NSURLConnection
。我怎么知道问题到底是什么,我该如何解决? 我已经把苹果提供的Reachability方法,但返回YES
来互联网可达性和主机可达性。只是因特网连接速度很慢。 快速连接(Wifi),它工作得很好。
编辑:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[window setFrame:[[UIScreen mainScreen] bounds]];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
//singleton
u=[[U5 alloc]init];
m_tUSyncPersistableConfig = [[USyncPersistableConfig alloc] init] ;
m_commonObj = [[CommonClass alloc] init] ;
u.m_tUSyncPersistableConfig=m_tUSyncPersistableConfig;
u.commonObj = m_commonObj;
//register for push notifications
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound)];
//load persisting data : from sqlite database
[u loadPreferences:m_tUSyncPersistableConfig];
window.rootViewController = tabBarController;
[window makeKeyAndVisible];
if (![[NSUserDefaults standardUserDefaults] boolForKey:@"HasLaunchedOnce"]) {
//first launch//setting some values
}else {
//not first launch
}
if (![[NSUserDefaults standardUserDefaults] boolForKey:@"HasLaunchedOnce"] || [u.m_tUSyncPersistableConfig.mUserName isEqualToString:@""] || !u.m_tUSyncPersistableConfig.mUserName)
{
// This is the first launch ever
//present login page
}
else
{
// app already launched
[[u commonObj] performSelectorInBackground:@selector(getAccountInfo) withObject:nil];
}
return YES;
}
你有没有检查:-http://stackoverflow.com/questions/10288133/ios-app-gets-sigkill-due-to-slow-network-connection –
这并不能解决我的问题。我打电话在后台线程中的所有连接方法,没有在主线程 –
http://stackoverflow.com/questions/10249377/nsurlconnection-delegate-methods-on-background-thread –