ios - dataWithContentsOfURL crash when running on iOS8 -



ios - dataWithContentsOfURL crash when running on iOS8 -

datawithcontentsofurl crashes on ios8 when host not reachable , there net connection.

nsurl *url = [nsurl urlwithstring:myurl]; @try { info = [nsdata datawithcontentsofurl:url]; } @catch (nsexception *exception) { info = nil; } if(data!=nil){ [data writetofile:filepath atomically:yes]; }else{ info = [nsdata datawithcontentsoffile:filepath]; if (data==nil) { homecoming nil; } }

from documentation:

important: not utilize synchronous method request network-based urls. network-based urls, method can block current thread tens of seconds on slow network, resulting in poor user experience, , in ios, may cause app terminated.

if need know reason failure, utilize datawithcontentsofurl:options:error:

or

instead, non-file urls, consider using datataskwithurl:completionhandler: method of nssession class.

ios iphone ios8

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -