objective c - Checking if NSArray contains block -
Is it safe to check the existence of special blocks within the NSArray? Suppose we have this code:
int (^ blockA) (int) = ^ (int x) {return x; }; Int (^ blockb) (int) = ^ (int x) {returns x; }; NSArray * array = [NSArray arrayWithObjects: [Block A copy], [Block B copy], zero]; If ([array included object: block A]) {NSLOG (@ "IDX:% D", [array index of object: block]); } If ((include the array: Block B)) {NSLOG (@ "IDX:% D", [array index OF object: blockb]); } The output I get is:
idx: 0 idx: 1 So it appears Working, but I'm not sure why, especially because the array is copies of the original blocks whose execution is same. Is there any internal identifier in each block or what? This work will be appreciated, detail about this.
Block A and [Block will not happen on a per] usually object, so [array contains objects: Block] would not be likely to return For example, you have to write block A = [block A copy] before , you must add it to the array.
Comments
Post a Comment