Questions tagged [nsnumber]

on Mac OS X, NSNumber is a subclass of NSValue that offers a value as any C scalar (numeric) type

NSNumber is a subclass of NSValue that offers a value as any C scalar (numeric) type. It defines a set of methods specifically for setting and accessing the value as a signed or unsigned char, short int, int, long int, long long int, float, or double or as a BOOL. (Note that number objects do not necessarily preserve the type they are created with.)

Resource

785 questions
-1
votes
2 answers

Convert NSNumber to long

I am trying to convert a NSNumber to long but I get this error: [__NSSingleObjectArrayI intValue]: unrecognized selector sent to instance Here is my code: NSNumber *dbversion = [settings valueForKey:@"Version"]; long dbver = [dbversion…
Steve
  • 1
  • 4
-1
votes
1 answer

How to add two hexadecimal strings and get total in third string?

I have two strings which are hex value for some number now I want to add them and want the result in the hex values which is also a string.
Satish Mavani
  • 4,897
  • 2
  • 20
  • 30
-1
votes
3 answers

Binary operator '+' cannot be applied to two 'NSNumber' operands -- swift 3

Help. I just converted to swift 3 and am getting errors when I try to add two NSNumbers together i.e.: var foodPrice: NSNumber! var priceSum: NSNumber! foodPrice = 6.79 priceSum = 11.89 var totalSum = NSNumber(foodPrice + priceSum) // <-- error…
David Villegas
  • 458
  • 3
  • 18
-1
votes
1 answer

NSNumbers and it's value representation issue

Explanation Why this is not a duplicate of that pointed Q&A!: I encountered this problem in relation to Objective-C minor implementation and NSNumber type has varying floating point precision and I just needed to know what really happens and what…
Randika Vishman
  • 7,983
  • 3
  • 57
  • 80
-1
votes
1 answer

NSNumber initialization issue

Recently I found interesting problem connected with NSNumber initialization. The difference occurred between simulator (9.3.1) and device (9.3.1). Let assume that we've got int x = 2; Now we're initializing NSNumber and passing it to a…
Piotr Gawłowski
  • 189
  • 1
  • 10
-1
votes
2 answers

Ints in loop of days continues to repeat for all days

I have tried changing my functions that get the start of day/end of day NSDates several times and I know the loop is working bc its printing out the right days of the week, but the start_timestamp and end_timestamp for each day is showing up the…
ChuckKelly
  • 1,742
  • 5
  • 25
  • 54
-1
votes
1 answer

NSInteger vs NSNumber and retrieving JSON data from itunes

Im trying to grab the artistId from this JSON { "wrapperType": "track", "kind": "podcast", "artistId": 125443881, "collectionId": 523121474, "trackId": 523121474, when creating my podcast object. but when i try to display this variable as…
-1
votes
2 answers

NSPredicate with IN NSNumbers

I have set up an NSPredicate to check if the object category_id is IN in an NSArray of numbers. The code: ///This is working NSArray *arr2 = [[NSArray alloc]initWithObjects:@[@3,@2,@3],nil]; [NSPredicate predicateWithFormat:@"category_id IN %@",…
BlackM
  • 3,927
  • 8
  • 39
  • 69
-1
votes
2 answers

NSNumber returns wrong value

I have NSDictionary and I assign value of 'price' key to NSNumber property of my object but when I log number value, it is an strange negative number! item.price = [food valueForKey:@"price"]; price property is NSNumber [[food valueForKey:@"price"]…
Hashem Aboonajmi
  • 13,077
  • 8
  • 66
  • 75
-1
votes
1 answer

Converting Variable from Obj-C To Swift

I want to convert these two variables into Swift language but I cant seem to figure out the best way to do this bc of the fact that dateWithTimeIntervalSinceNow works differently in swift. NSNumber *startDate = @((unsigned long long)([[NSDate…
Justin
  • 243
  • 5
  • 15
-1
votes
2 answers

Subtracting Currency - NSNumber

Im dealing with currency values that I need to subtract from each other. I read that NSNumber is good for dealing with currency, however I am unable to subtract two NSNumbers. Is there a better way for dealing with currencys or am I missing…
DevC
  • 6,982
  • 9
  • 45
  • 80
-1
votes
1 answer

Unable to read NSNumber correctly

I'm trying to read back two NSNumber values that I've written to NSUserDefaults (24 and 39993). I can write the values just fine, but reading it back gives completely different values than expected. If the NSNumber was able to be read correctly I…
Joe Habadas
  • 628
  • 8
  • 21
-1
votes
1 answer

Why when saving an NSINteger to NSSNumber results in NSNumber having random weird result

item.itemId is in coredata as an NSNumber and itemModel.itemID is a NSInteger. When saving itemModel.itemId to the itemId in core data it prints out -31016 for item.ItemID and 100056 for the NSInteger. The following two lines prints out -31016…
user1898829
  • 3,437
  • 6
  • 34
  • 62
-1
votes
1 answer

Casting an NSTimeInterval as a NSNumber within a block

I'm having difficulty within a block with assigning an NSTimeInterval value to an NSNumber Here is what I have so far: [player addPeriodicTimeObserverForInterval:CMTimeMake(3, 10) queue:NULL usingBlock:^(CMTime time){ NSTimeInterval…
Linda Keating
  • 2,215
  • 7
  • 31
  • 63
-1
votes
1 answer

Swift convert int nsmanagedobject to .text

I have a cordite model. One of the attributes is an NSNumber, @NSManaged var playerOneScore: NSNumber I'm trying to fetch this and store it in a text label. playerOnePar.text = myArray[0].valueForKey("playerOneScore") as String It doesn't like…
candidaMan
  • 791
  • 1
  • 7
  • 12