Calling NSException.raise() in Swift

后端 未结 3 1559
遥遥无期
遥遥无期 2021-02-20 06:26

I\'m trying to raise an exception in Swift by calling NSException.raise(). The definition is:

class func raise(_ name: String!, format format: String!, arguments         


        
3条回答
  •  悲&欢浪女
    2021-02-20 07:22

    var e = NSException(name:"name", reason:"reason", userInfo:["key":"value"])
    e.raise()
    

    Or:

    var e = NSException(name:"name", reason:"reason", userInfo:nil)
    e.raise()
    

    Or:

    NSException(name:"name", reason:"reason", userInfo:nil).raise()
    

提交回复
热议问题