I have an array of views, and I need to hide them all, so I use:
BOOL shouldHideViews = YES;
[allViews makeObjectPerformSelector:@selector(setHidden:) withObject:(void *)shouldHideViews]
When I convert the code to ARC, it tells me I need some bridged cast, then I changed:
(void *)shouldHideViews
to
(__bridge BOOL)shouldHideViews
it says incompatible types casting ‘int’ to ‘BOOL’ with a __bridge cast
So how do I do it? I know I can just iterate all the views in the array, but this is not the point, I want to know in general what I should do to make this ARC compatible.
Thanks!
The other answers indicating that you can’t pass
YESthis way are correct. There are easier solutions however:This works because NSArray overrides its
setValue:forKey:for exactly this use.You can also now use blocks:
Or the tried and true
for()loop (see @rob mayoff’s answer.)Of them, I generally just use a
forloop.