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.
Questions tagged [nsvalue]
64 questions
0
votes
0 answers
Convert the NSValues to a CGPoint
I need to convert NSValues from a dictionary to CGPoint.
Example: I have a dictionary with 2 items in it:
NSValue *p1 = [dict objectForKey:@"LATITUDE"];
NSValue *p2 = [dict objectForKey:@"LONGITUDE"];
When I try this, it gives an error
CGPoint…

sia
- 1,872
- 1
- 23
- 54
0
votes
2 answers
How to Represent Dictionary as NSValue in Swift 3?
I have the following Dictionary:
let example: [String: (Int, Int)] = ["test": (0, 1)]
I need to store this as an NSData variable, and to do that it must first be converted to an NSValue, which I try to do as follows:
let nsval =…

Brandon Bradley
- 3,160
- 4
- 22
- 39
0
votes
1 answer
Swift - Array of SCNVector4 to NSValue?
How can I convert an array of vector to an NSValue? There is a convenience initiation for a single SCNVector4 for instance, but how can I use that for an array?
Like:
let v1 = SCNVector4(x: 0.0, y: 0.0, z: 0.0, w: 0.0)
let v2 = SCNVector4(x: 1.0, y:…

Guig
- 9,891
- 7
- 64
- 126
0
votes
2 answers
wrap & unwrap with NSValue
In my project, I have a function like this:
- (void)doSomething:(NSError**)error {
...
}
I need to call this function on another thread by using function performSelector:onThread:withObject:waitUntilDone: , something like this:
[self…

Leem.fin
- 40,781
- 83
- 202
- 354
0
votes
2 answers
Get reference to the NSObject in an NSValue
I have an NSMutableDictionary which contains UIImageView objects and UIView keys.
When I am setting an UIImageView to the NSMutableDictionary I get the NSValue out from the UIView like this:
[viewImageMap setObject:anImage forKey:[NSValue…

JLT
- 3,052
- 9
- 39
- 86
0
votes
1 answer
Get CGPoint value from NSValue in array
Trying to extract CGPoint values from my allCenters array, which contains NSValues. They were converted to NSValues from CGPoints initially. I know that this code is what I'm trying to do, but I guess it doesn't work in SWIFT 2: CGPoint randLoc =…

James D. Schwartz
- 95
- 1
- 12
0
votes
1 answer
How to convert IMP to NSValue with Swift?
I want convert the implementation to NSValue, but it's err.
In Objective-C, can use this line to convert:
[NSValue valueWithPointer:implementation]
but in Swift, how to convert?

Robin.Chao
- 103
- 9
0
votes
0 answers
NSValue SCNVector3 crash
I create NSValue objects from SCNVector3 structs.
NSValue *value = [NSValue valueWithSCNVector3:vector]
After that I add them to dictionary. Whenever I try to access value from dictionary app crashes, but only in release mode. Trivial stuff looks…

b.zdybowicz
- 166
- 9
0
votes
1 answer
How to get a NSRange Value from NSConcreteValue?
The code is like this. My question is how to get the NSRange value from the id type?
-(void)clicText:(MyLabel *)label clickedOnLink:(id)linkData{
NSString *message = [NSString stringWithFormat:@"LinkData is %@:%@",[[linkData class]…

user4246451
- 57
- 5
0
votes
1 answer
Convert NSValue back to CGPoint
I made an NSMutableArray like this storing a bunch of CGPoints
safeZonePoints = [NSMutableArray array];
[safeZonePoints addObject:[NSValue valueWithCGPoint:CGPointMake(234, 160)]];
[safeZonePoints addObject:[NSValue…

the pickle
- 668
- 8
- 18
0
votes
3 answers
Cross-platform NSValue category
I am trying to create a cross-platform NSValue category that will handle CGPoint/NSPoint and CGSize/NSSize etc, for Cocoa and iOS.
I have this:
#ifdef __MAC_OS_X_VERSION_MAX_ALLOWED
// Mac OSX
+ (NSValue *) storePoint:(NSPoint)point {
return…

Duck
- 34,902
- 47
- 248
- 470
0
votes
1 answer
Number of object is only one while adding multiple imageview frames
i m new to ios
I am using a nsvalue to get frame of image view in a Array. but when i log the count of array it says only 1.
I am using this array to somewhere else to retrieve the frames.
Can you please tell me how i can get the array count as…

Vikas Soni
- 21
- 4
0
votes
1 answer
Struct wrapped in NSValue memory issues
I currently have this function which init's my user defaults:
+ (void)initialize
{
// Create a dictionary to hold the default user preference values
NSMutableDictionary *defaultValues = [NSMutableDictionary dictionary];
// Put defaults…

guitarflow
- 2,930
- 25
- 38
0
votes
1 answer
NSValue or NSObject subclass
In my application I need to put some c-struct-like data into an NSMutableArray.
After some research I found that the most suggested solution is to wrap the struct into NSValue and insert that into the array.
What about creating a custom subclass of…

Jacopo
- 1,031
- 2
- 12
- 25
0
votes
1 answer
Storing NSMutableArray
I am currently storing an instance of a class in an NSMutableArray by using NSValue with "valueWithPointer". The problem is within this class I have another NSMutableArray, whenever I convert the instance of the class back from NSValue the…

IApp
- 667
- 1
- 6
- 18