Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is an NSConcreteValue and how do I extract its value?

I have a library where I am receiving NSConcreteValue and I have no idea how to deal with it. I know the object I am supposed to get is a boolean, so how do i extricate the real value?

like image 427
John Smith Avatar asked Jan 06 '11 14:01

John Smith


1 Answers

That’s a private class that’s sometimes (or all the times?) used behind the scenes when you work with NSValue. Or at least that’s my impression. I think you should be able to cast to NSValue:

// assuming value is of type “id”
NSAssert([value isKindOfClass:[NSValue class]],
    @"Sorry, I was wrong. Maybe try anyway?");
NSAssert(strcmp(@encode(BOOL), [value objCType]) == 0,
    @"The value does not seem to hold a BOOL.");
BOOL unwrappedValue;
[value getValue:&unwrappedValue];

…or something like that, I’m making this up :-)

like image 99
zoul Avatar answered Oct 06 '22 18:10

zoul