Using makeObjectsPerformSelector:withObject: with a false boolean

前端 未结 3 1159
谎友^
谎友^ 2021-01-19 05:45

I\'ve got an array of UITextField objects called _fields. I want to be able to message them all at once to set them to be highlighted,

3条回答
  •  醉酒成梦
    2021-01-19 05:52

    rmaddy's answer explains why using makeObjectsPerformSelector:withObject: won't work.

    You can do this most succinctly by using KVC:

    [fields setValue:@NO forKey:@"hidden"];
    

    This works because NSArray passes the setValue:forKey: message through to each of its elements, and KVC properly unwraps the boxed value when the property's type is primitive.

提交回复
热议问题