i have array of buttons (IBOutletCollections) name "topFriends"..i need to set hidden the all buttons of topFriends(array name).
[self.topInFriends makeObjectsPerformSelector:@selector(setHidden:) withObject:[NSNumber numberWithBool:YES]];
Actually its working on iOS7...but its not working on iOS 7.1 .
but when i try to enumerate the array like following,then its working for iOS7 and 7.1
[self.topInFriends enumerateObjectsUsingBlock:^(UIButton * obj, NSUInteger idx, BOOL *stop) {
obj.hidden=YES;
}];
Can anyone please tell me why makeObjectsPerformSelector function not working in iOS 7.1 .I am really frustrated to find the issue..please anyone help me..thanks in advance
I got this from the docs of makeObjectsPerformSelector
and this is the description of the parameter SEL
in this method
A selector that identifies the message to send to the objects in the array. The method must take a single argument of type id, and must not have the side effect of modifying the receiving array.
Then I run this line
[self.topInFriends makeObjectsPerformSelector:@selector(setHidden:)
withObject:@"Fcuked up"];
It hides the button, So it doesn't matter what you are passing. And it makes sense too as your method expect a BOOL
and you are giving an object to it, I don't know the exact internal implementation of makeObjectsPerformSelector
but I can conclude some points
When you pass some object say @"abc"
or @YES
and when makeObjectsPerformSelector
invokes your setHidden
then it's passing object, which obviously has some address too, to setHidden
and it converts your object(address) into BOOL
.
Suppose your addresses are
@"Fcuked up" ---> 0x7cde450034798976 (assuming 64 bit pointer)
@YES ---> 0x7cde450000000000
For first case the value of BOOL
will become true as it's LSB are non-zero and for second case the BOOL
will become false as LSB are zeros.
id
All thoughts appearing in this answer are mine. Any resemblance to other persons, living or dead, is purely coincidental.