小编iro*_*oei的帖子

NEHotspotConfigurationManager收到此警报:“无法加入网络<网络名称>”,错误为零

所以我试图通过更紧密的监视连接状态:

 func reconnect(success: @escaping () -> Void, failure: @escaping () -> Void) {
    let manager = NEHotspotConfigurationManager.shared
    let ssid = CameraManager.camera.uuid
    let password = "password"
    let isWEP = false
    let hotspotConfiguration = NEHotspotConfiguration(ssid: ssid, passphrase: password, isWEP: isWEP)
    hotspotConfiguration.joinOnce = true
    manager.apply(hotspotConfiguration) { (error) in
        if (error != nil) {

          if let error = error {
                switch error._code {
                case 8:
                    print("internal error")
                    failure()
                case 7:
                    NotificationCenter.default.post(name: Notification.Name(rawValue: "cancelFromHotSpot"), object: nil)
                    failure()
                    self.stopSession()
                case 13:
                    success()
                    DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) …
Run Code Online (Sandbox Code Playgroud)

ios swift networkextension hotspot nehotspothelper

6
推荐指数
1
解决办法
743
查看次数

iOS - 在 Localizable.strings 中用粗体字符串强调

有没有办法像这样在 Localizable 文件中加粗一些单词?

"Pending network connection" = "<b>Pending</b> network connection";
Run Code Online (Sandbox Code Playgroud)

我在里面有这个字符串,我只想强调某些单词:

 "camSave" = "To complete onboarding:\n1. Tap Save and disconnect to disconnect from the camera.\n2. Connect to the internet.\n3. Log in to Cloud.";
Run Code Online (Sandbox Code Playgroud)

顺便说一句,我想在警报中使用它

localization nsattributedstring localizable.strings ios swift

5
推荐指数
2
解决办法
1711
查看次数

iOS-键入时验证用户IP地址

所以我想在输入时验证用户的IP。在VC中,我执行以下操作:

extension NetworkSettingsViewController: UITextFieldDelegate {
  func textFieldShouldReturn(_ textField: UITextField) -> Bool {
    self.staticMask.resignFirstResponder()
    self.staticGateway.resignFirstResponder()
    self.staticIp.resignFirstResponder()
    self.staticDns.resignFirstResponder()
    return true
}

func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {

    var isValidate: Bool
    //verify deletion not happening 
    if !(range.length == 1) {
        if validatorManager.verifyTarget(test: string) {

            isValidate = true
        } else {
            isValidate = false
        }
    } else {
        isValidate = true
    }
    return isValidate
}
Run Code Online (Sandbox Code Playgroud)

}

这是验证类:

 class ValidatorManager: NSObject {

   func verifyTarget(test: String) -> Bool { …
Run Code Online (Sandbox Code Playgroud)

regex uitextfield ios uitextfielddelegate swift

4
推荐指数
1
解决办法
728
查看次数

iOS - cocoapods 不更新

我有自己的 pod,已上传到 cocoa。我已经上传了新的代码行,我可以在存储库中看到它们,我可以在项目中的 pod 中看到它们,但它们仍然没有执行。

吊舱规格: 在此输入图像描述

podspec 中的新代码行: 在此输入图像描述

任何想法?

在存储库中添加新代码行: 在此输入图像描述

ios cocoapods podspec swift

3
推荐指数
1
解决办法
4888
查看次数

iOS MobileVLCKit 存档问题

在尝试归档我的项目时,我收到此错误

ld: bitcode bundle could not be generated because '/Users//MobileVLCKit/MobileVLCKit.framework/MobileVLCKit(VLCEmbeddedDialogProvider.o)' was built without full bitcode. All object files and libraries for bitcode must be generated from Xcode Archive or Install build file '/Users//MobileVLCKit/MobileVLCKit.framework/MobileVLCKit' for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Run Code Online (Sandbox Code Playgroud)

尝试这样做,enablebitcode = no 但是当我存档时,mac 卡住了,40 分钟后我放弃了。

知道我能做什么以及是否可以使用此 pod 归档项目?

vlc archive ios swift bitcode

2
推荐指数
1
解决办法
2263
查看次数

iOS - 由于“内部”保护级别(来自我的 pod),“val”无法访问

所以我已经构建了一个 pod,我正在尝试在我的项目中使用它。我有这个数据结构:

public struct Device {
  public init() {}

  var id: String = ""
  var serial: String = ""
  var account: String = ""
  var name: String = ""
  var isAttached: Bool?
  var isShared: Bool?
}
Run Code Online (Sandbox Code Playgroud)

我在解析器中有这个函数:

func getDevices(json: JSON) -> [Device] {
    var devices = [Device]()

    for device in json.arrayValue {
        var item = Device()
        item.account = device["account"].string!
        item.id = device["id"].string!
        item.isAttached = device["isAttached"].boolValue
        item.isShared = device["isShared"].boolValue
        item.name = device["name"].string!
        item.serial = device["serial"].string!
        devices.append(item)
    }
    return devices
}
Run Code Online (Sandbox Code Playgroud)

以及 …

json ios swift swifty-json

0
推荐指数
1
解决办法
5074
查看次数

定时器在 invalidate() 和 nil 之后继续工作

我有这个计时器:

class InstallationViewController: BaseViewController {

   var precentageTimer: Timer!
}
Run Code Online (Sandbox Code Playgroud)

在同一堂课中,我像这样启动计时器:

               self.precentageTimer = Timer.scheduledTimer(withTimeInterval: 0.1, repeats: true, block: { (timer) in
                self.network.getClibrationPercentage(success: { (info, percent) in
                    self.isAnalysisCompleted(percent: percent)
                    self.precentageLbl.text = "\(percent)%"
                    self.instructionsLbl.text = info
                    self.precentageLbl.isHidden = false
                }, failure: { (error) in
                    print(error)
                })
            })
Run Code Online (Sandbox Code Playgroud)

我也有这样的方法来解除任务:

 func dissmissAllTasks() {
    NotificationCenter.default.removeObserver(self)
    self.setCalibrationEnableTimer?.invalidate()
    self.setCalibrationEnableTimer = nil
    self.snapShotTimer?.invalidate()
    self.snapShotTimer = nil
    self.precentageTimer?.invalidate()
    self.precentageTimer = nil
}
Run Code Online (Sandbox Code Playgroud)

当我像这样单步执行 viewWillDisappear 时就会发生这种情况:

override func viewWillDisappear(_ animated: Bool) {
    super.viewWillDisappear(animated)
    dissmissAllTasks()
 }
Run Code Online (Sandbox Code Playgroud)

但当我去其他 VC 时,我可以看到这个计时器一直在持续。我检查了调用的 dissmissAllTask​​s() ,我可以看到计时器为零。

为什么计时器一直走?

timer nstimer ios swift

-1
推荐指数
1
解决办法
639
查看次数