views:

600

answers:

1

I'm using KVC to iterating through a few views. Having trouble setting BOOL properties:

[self setValue:YES forKeyPath:[NSString stringWithFormat:@"myView%d.userInteractionEnabled", n]];

I get: warning: passing argument 1 of 'setValue:forKeyPath:' makes pointer from integer without a cast.

There is no [NSValue valueWithBool:YES] or similar that I can find.

What to do?

+12  A: 

The compiler is generating a warning because the first argument of -setValue:forKeyPath: expects and object. YES is not an object.

The answer is right there in "NSValue.h":

[NSNumber numberWithBool: aBool]

Jim Correia