NSData contentsOfUrl returns nil

前端 未结 2 954
野的像风
野的像风 2021-01-05 15:25

I found several similar questions on StackOverflow but none of them solve my problem.

I am trying to get a image from a url. Here\'s how I do it:

let         


        
2条回答
  •  無奈伤痛
    2021-01-05 15:45

    This is probably a result of Apple's new app transport security denying a non-HTTPS request. To work around this you need to modify your app's Info.plist file. You can either define an exception for that particular domain

    NSAppTransportSecurity
    
        NSExceptionDomains
        
            pic3.zhimg.com
            
                NSIncludesSubdomains
                
                NSTemporaryExceptionAllowsInsecureHTTPLoads
                
            
        
    
    

    or disable ATS altogether

    NSAppTransportSecurity
    
        NSAllowsArbitraryLoads
        
    
    

提交回复
热议问题