【发布时间】:2016-10-07 10:33:42
【问题描述】:
如果用户在我的 xcode swift 应用程序中没有 Internet 连接,我想提醒他们,因此我使用 Reachablity 来执行此操作。但是当我在 Viewcontroller 中实现我的代码时,我收到了这个错误:
预期声明
我也尝试将我的代码放入viewdidload,但没有成功。
这是代码:
if Reachability.checkIntenetRechable() == false {
let alertView = UIAlertCole: "APP_NAME", message: "Please check your internet connection.", preferredStyle: UIAlertControllerStyle.Alert)
//alertView.addAction(UIAlertAction(title: "Cancel", style: UIAlertActionStyle.Cancel, handler: { (action: UIAlertAction ) in }))
alertView.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: { (action: UIAlertAction ) in
// Put some code for okay button
}))
self.presentViewController(alertView, animated: true, completion: nil)
}
【问题讨论】:
-
我们在 Reachability.swift 文件中添加了 checkIntenetRechable() 方法。
-
@mr-bista 看起来我们的编辑发生了冲突或其他什么,你的我的无效,并且已经恢复了拼写错误和大写错误。 :/(固定)
-
您是否在 Reachability 文件中添加了这个 checkIntenetRechable() ?如果没有,请根据我的帖子添加
标签: ios swift reachability