Get a Swift Variable's Actual Name as String

后端 未结 6 2036
借酒劲吻你
借酒劲吻你 2020-11-29 04:40

So I am trying to get the Actual Variable Name as String in Swift, but have not found a way to do so... or maybe I am looking at this problem and solution in a bad angle.

6条回答
  •  爱一瞬间的悲伤
    2020-11-29 05:13

    As per the updated from this answer, it is supported in Swift 3 via #keyPath

    NSPredicate(format: "%K == %@", #keyPath(Person.firstName), "Andrew")
    

提交回复
热议问题