NSUserDefaults - How to tell if a key exists

前端 未结 11 1806
耶瑟儿~
耶瑟儿~ 2020-12-12 11:06

I\'m working on a small iPhone app, and I am using NSUserDefaults as my data persistence. It only has to keep track of a few things, such as some names and som

11条回答
  •  独厮守ぢ
    2020-12-12 11:40

    Swift 3.0

    if NSUserDefaults.standardUserDefaults().dictionaryRepresentation().contains({ $0.0 == "Your_Comparison_Key" }){
                        result = NSUserDefaults.standardUserDefaults().objectForKey(self.ticketDetail.ticket_id) as! String
                    }
    

提交回复
热议问题