我想要完成的是
Person *person1 = [[Person alloc]initWithDict:dict];
然后在NSObject
“人”中,有类似的东西:
-(void)initWithDict:(NSDictionary*)dict{
self.name = [dict objectForKey:@"Name"];
self.age = [dict objectForKey:@"Age"];
return (Person with name and age);
}
然后,我可以继续使用带有这些参数的 person 对象。这可能吗,还是我必须做正常的
Person *person1 = [[Person alloc]init];
person1.name = @"Bob";
person1.age = @"123";
?