小编Edg*_*gel的帖子

如何在swift 2中获取Alamofire.request().responseJSON的结果值?

我有一个关于新版Alamofire for Swift 2的问题

Alamofire.request(.POST, urlString, parameters: parameters as? [String : AnyObject])
        .responseJSON { (request, response, result) -> Void in
            let dico = result as? NSDictionary
            for (index, value) in dico! {
                print("index : \(index)     value : \(value)")
            }
    }
Run Code Online (Sandbox Code Playgroud)

在本节中,我想将结果转换为NSDictionary.但是当我编译并设置断点时,调试器说dico是零.如果我使用debugDescription打印结果,它不是nil并包含我所期望的如何转换Result变量?

json ios swift alamofire swift2

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

setTitle(_ title:String?,for state:UIControlState)where .Normal state?

我在Xcode 8上用iOS10将我的应用更新为Swift 3,我收到错误:

Btn.setTitle('str', forState: .Normal)
Run Code Online (Sandbox Code Playgroud)

.Normal不再是UIControlState的枚举类型.我应该将哪种类型的UIControlState用于此状态?

Apple枚举现在定义为

public struct UIControlState : OptionSet {

   public init(rawValue: UInt)


   public static var highlighted: UIControlState { get } // used when UIControl isHighlighted is set

   public static var disabled: UIControlState { get }

   public static var selected: UIControlState { get } // flag usable by app (see below)

   @available(iOS 9.0, *)
   public static var focused: UIControlState { get } // Applicable only when the screen supports focus

   public static var application: UIControlState { …
Run Code Online (Sandbox Code Playgroud)

uicontrolstate swift swift3 ios10

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

标签 统计

swift ×2

alamofire ×1

ios ×1

ios10 ×1

json ×1

swift2 ×1

swift3 ×1

uicontrolstate ×1