本文包含:Mac开发中网络通讯常见问题、Mac端 网络通讯demo。
错误一:
输出台:App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file......

原因:要求App内访问网络请求,要采用 HTTPS 协议。
解决办法:
1、在Info.plist中添加 NSAppTransportSecurity 类型 Dictionary ;
2、在 NSAppTransportSecurity 下添加 NSAllowsArbitraryLoads 类型Boolean ,值设为 YES;

错误二:
输出台:dnssd_clientstub ConnectToServer: connect()-> No of tries: 1......

原因:Capabilities 中 Networking 未打开
解决办法:
点击target,选择Capabilities,然后在Sandox项目下的Networking两个选项前面打钩。

网友评论