Questions tagged [nsvalue]

An NSValue object is a simple container for a single C or Objective-C data item. It can hold any of the scalar types such as int, float, and char, as well as pointers, structures, and object ids. The purpose of this class is to allow items of such data types to be added to collections such as instances of NSArray and NSSet, which require their elements to be objects. NSValue objects are always immutable.

64 questions
0
votes
2 answers

NSValue to NSNumber conversion crash

I want to convert NSValue to NSNumber. What is wrong with this code? char value[4]; [myNSValue getValue:(void*)value]; NSNumber *number = [[NSNumber alloc] initWithBytes:(void*)value objCType:[myNSValue objCType]]; NSTimeInterval duration = [number…
pro_metedor
  • 1,176
  • 10
  • 17
0
votes
2 answers

Passing object pointer to performSelector:withObject results in EXC_BAD_ACCESS

Here is the problem: I am passing a pointer to an object to performSelector:withObject via [NSValue valueWithPointer:] for example like this: // GVertex is NSObject subclass GVertex *vertex = [[GVertex alloc] initWithX:5.0f andY:4.5f]]; GVertex…
iska
  • 2,208
  • 1
  • 18
  • 37
0
votes
1 answer

Getting an int out of NSConcreteValue / NSValue

I am trying to extract an int inside of a NSValue / NSConcreteValue instance. I tried to cast them this way, but it didn't work: NSValue *toValue = (NSValue *)someValue; NSNumber *toNumber = (NSNumber*)toValue; int final = [toNumber…
Andrew Lauer Barinov
  • 5,694
  • 10
  • 59
  • 83
-2
votes
1 answer

Compare NSValue with a string

I have the following code NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; NSValue *state = [defaults objectForKey:@"screenstatus"]; Here the state holds a string value for the key screen status. I need to get the value of the…
Timothy Rajan
  • 1,947
  • 8
  • 38
  • 62
1 2 3 4
5