每當遇到連接問題,在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 –