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
1
vote
1 answer
Swift NSCoding with NSValue
Isn't NSValue an NSObject ? So why am I crashing on
var coordinatesRawData = NSValue(MKCoordinate: coordinates.first!)
if coordinatesRawData != nil {
// Crashing here. I have a valid NSValue object
…

DogCoffee
- 19,820
- 10
- 87
- 120
1
vote
0 answers
How do convert NSValue to CLLocationCoordinate?
I tried to store CLLocationCoordinate2D to NSMutableArray but I could only do it using NSValue. I want to get those coordinates stored in NSMutableArray in NSValue type as CLLocationCoordinate2D. How can I do that? I am having trouble getting those…

Rosh
- 169
- 16
1
vote
1 answer
How to store objects in plist
I have some CGPoints that I need to store in a NSDictionary then write to a file. Later, I need to be able to load the file into a NSDictionary and access the CGPoint within.
self.dict is the NSDictionary I want to store points in.
-…

TheCodeMan54
- 143
- 2
- 5
1
vote
2 answers
Getting values from NSValue that was created using sizeWithAttributes
I have an NSValue that I am returning from an NSDictionary. The NSValue was created using sizeWithAttributes.
I would like to know how to get the NSValue back into a value where I can use it to create the label size.
I get the size of the label…

HurkNburkS
- 5,492
- 19
- 100
- 183
1
vote
1 answer
NSValue to CLLocationCoordinate2D in Swift
I am using Contentful.com as a content-backend for my iOS app. I can not get their geo-point return to work for me in my Swift project.
The Contentful documentation says their API returns "NSData with CLLocationCoordinate2D struct."
I am…

schnabler
- 687
- 7
- 23
1
vote
0 answers
RedLaser iOS SDK returns nan for barcodeLocation in iOS 8
I am using RedLaser iOS SDK for my app. I used barcodeLocation property to identify if the barcode lies inside my active region frame. In iOS 8.1,that property returns nan. Hence I could not do the precise level of scanning. Is there any…

user709877
- 69
- 8
1
vote
0 answers
XPC method not invoked with NSArray of NSValues as parameter
I have an XPC service compiled 32-bit for OS-X. One of it's methods takes a single argument as a parameter, and calls a given block back on the main process.
This block takes 3 NSStrings and an NSArray that's supposed to contain NSValues solely.…

Niv
- 2,294
- 5
- 29
- 41
1
vote
3 answers
Does NSValue free its value when freed?
Have a look at this pseudocode:
void* magicpointer = malloc(OVER_NINE_THOUSAND);
NSValue* v = [NSValue valueWithPointer:magicpointer];
[v release];
When v is released, does magicpointer get freed as well, or do I have to do that manually? I am…

Georges Oates Larsen
- 6,812
- 12
- 51
- 67
0
votes
1 answer
How to create an NSValue from the addition of a pointer and an integer?
I need to create a key for an NSMutableDictionary. The ideal key would be the merger of a pointer and an integer.
This will work for just the pointer
NSValue *key = [NSValue valueWithPointer:somePointer];
How do I add together somePointer + someInt…

dugla
- 12,774
- 26
- 88
- 136
0
votes
1 answer
How to print NSValue bytes
How does one print NSValue bytes? When using print it doesn't print all the bytes and puts '...'. E.g. {length = 128, bytes = 0x00000000 0000f03f 00000000 00000000 ... 00000000 0000f03f }
import Cocoa
import SceneKit
var identityMatrix =…

bhartsb
- 1,316
- 14
- 39
0
votes
1 answer
Cannot get value with size 16. The type encoded as {?={CGPoint=dd}d} is expected to be 24 bytes
This error appears when trying to get a CGPoint from NSValue:
"Cannot get value with size 16. The type encoded as {?={CGPoint=dd}d} is expected to be 24 bytes"
for (NSValue *p in array) {
CGPoint pointValue = p.CGPointValue; //Here appears…

Mario Monaco
- 1
- 2
0
votes
2 answers
Cast NSValue to CMTimeRange type swift 5.3
Swift 5.0 normally cast NSValue to CMTimeRange type, it does not supported in swift 5.3?
For example this worked correctly in Xcode 11.7 (Swift 5.0)
let nsValue = NSValue(timeRange: CMTimeRange(start: CMTime(seconds: 12, preferredTimescale: 1),…

Tayphoon
- 71
- 9
0
votes
1 answer
how to convert custom Objc struct to NSValue in Swift?
I define a custom struct in Objc
typedef struct {
int a;
int b;
} MyStruct;
In Objc I can convert the struct to NSValue use
MyStruct struct = {0};
NSValue *value = [NSValue value:&struct withObjCType:@encode(MyStruct)];
But how can I…

desmond_yy
- 83
- 6
0
votes
2 answers
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Invalid type in JSON write (NSConcreteValue)
This is my dictionary:
{ @"RoutePolyline":<__NSArrayM 0x283983750>(),
@"RideID":6565
};
I am sending this dictionary as an argument in my API call.
and my app crashes at this line of code:
NSData…

Ghazalah
- 233
- 2
- 14
0
votes
2 answers
Storing a dispatch_source_t in an NSMutableDictionary
If I try to use a dispatch_source_t as the key in an NSMutableDictionary:
dispatch_source_t source = dispatch_source_create(stuff...);
NSMutableDictionary filesAndSources = [NSMutableDictionary…

Steve Mills
- 63
- 8