ios - can't get image from URL? (NSURLErrorDomain error -1100) -
i trying load jpeg: https://i.groupme.com/638x640.jpeg.d4f31c747b534baca03d12db5a2b6193
but error the operation couldn’t completed. (nsurlerrordomain error -1100.)
from this post, found error means: kcfurlerrorfiledoesnotexist
. strange because there image there.
from this post, seemed issue https
protocol, after implemented solution switch http
, got error:
app transport security has blocked cleartext http (http://) resource load since insecure. temporary exceptions can configured via app's info.plist file.
... the resource not loaded because app transport security policy requires use of secure connection.
and same error continues popup after making necessary plist changes:
how download image in ios?
update
so found download ok https
if use code:
nsdata* thedata = [nsdata datawithcontentsofurl:[nsurl urlwithstring:@"https://i.groupme.com/638x640.jpeg.d4f31c747b534baca03d12db5a2b6193"]]; uiimage *image = [uiimage imagewithdata:thedata];
but doesn't work if use library: https://github.com/rs/sdwebimage
no 1 else seems have had issues https
, library though, think still settings problem on end?
you providing wrong domain name.
solution
delete plist settings have added manually, add in plist----
<key>nsapptransportsecurity</key> <dict> <key>nsexceptiondomains</key> <dict> <key>i.groupme.com</key> <dict> <key>nsincludessubdomains</key> <true/> <key>nsexceptionallowsinsecurehttploads</key> <true/> <key>nsexceptionrequiresforwardsecrecy</key> <true/> <key>nsexceptionminimumtlsversion</key> <string>tlsv1.2</string> <key>nsthirdpartyexceptionallowsinsecurehttploads</key> <false/> <key>nsthirdpartyexceptionrequiresforwardsecrecy</key> <true/> <key>nsthirdpartyexceptionminimumtlsversion</key> <string>tlsv1.2</string> <key>nsrequirescertificatetransparency</key> <false/> </dict> </dict> </dict>
plist screenshot
code download image
nsurl *url = [[nsurl alloc] initwithstring:@"https://i.groupme.com/638x640.jpeg.d4f31c747b534baca03d12db5a2b6193"]; nsdata *data = [[nsdata alloc] initwithcontentsofurl:url]; uiimage *result = [[uiimage alloc] initwithdata:data];
Comments
Post a Comment