我想知道NSObject和struct之间的区别.以下示例将解释这两种情况
指导
struct UserDetails{ var userName:String var userID:String var userAge:String func userDescription()->String{ return "name " + userName + "age " + userAge } }
在NSObject类中
class UserDetails: NSObject { var userName:String? var userID:String? var userAge:String? func userDescription()->String{ return "name " + userName! + "age " + userAge! } }
你能告诉我在哪里必须使用NSObject类,我必须使用struct ..?