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

Passing a double value number to a NSNumber from another viewController

I am having problems trying to pass a double value number to another viewController. This is the NSNumber declaration on the receiving viewController: @property (nonatomic, assign) NSNumber *lat; And this is how am I getting the value from the…
mvasco
  • 4,965
  • 7
  • 59
  • 120
-1
votes
2 answers

Dictionary problems for Objective C (NSNumber +NumberWithInt)

In writting my Dictionary for a CG thumbnail creation, if I map the value directly to an int It works perfectly: NSDictionary* d = [NSDictionary dictionaryWithObjectsAndKeys: (id)kCFBooleanTrue,…
cromestant
  • 652
  • 2
  • 10
  • 21
-1
votes
1 answer

Trying to do some simple calculations in iOS project?

I want to know how to do some simple equations in my iOS app, if anyone could point me in the right direction that would be wonderful! I need to know how to convert an NSNumber that represents minutes to an NSString which represents hours and…
Jon Sullivan
  • 399
  • 2
  • 5
  • 11
-1
votes
1 answer

Add number to NSNumber

I want to + and - some values to the current longitude: NSNumber *Latitude = [[NSNumber alloc] initWithDouble:location.latitude]; NSNumber *Longitude = [[NSNumber alloc] initWithDouble:location.longitude]; NSLog(@"Numbers:%@ %@", Latitude,…
David Raijmakers
  • 1,369
  • 1
  • 16
  • 40
-1
votes
2 answers

Does NSNumber add any extra bytes to the number it holds?

I'm working with Objective-C and I need to add int's from a NSArray to a NSMutableData (I'm preparing a to send the data over a connection). If I wrap the int's with NSNumber and then add them to NSMutableData, how would I find out how many bytes…
Josh Bradley
  • 4,630
  • 13
  • 54
  • 79
-2
votes
2 answers

How can I convert an array of NSNumbers to an array of Ints?

How to get Int value from NSNumber in Swift? Or convert array of NSNumber to Array of Int values? I have a list of NSNumber let array1:[NSNumber] I want a list of Int values from this array let array2:[Int] = Convert array1
Nav Brar
  • 202
  • 1
  • 9
-2
votes
2 answers

Unable to bridge NSNumber to Float

I'm runtime errors on my existing project when migrating versions of Xcode. Can someone help with this? Is my typecasting wrong? Code: let x = d[ChildItem.KEY_LOOK] as! NSArray as Array let y = d[ChildItem.KEY_COOR] as! NSArray as Array let…
Fra
  • 393
  • 7
  • 19
-2
votes
2 answers

Comparing NSNumber which contains float values

I am facing issue while comparing NSNumber. Below is my code: NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init]; [formatter setNumberStyle:NSNumberFormatterDecimalStyle]; NSNumber *avgRating= [formatter…
Vork
  • 746
  • 2
  • 12
  • 34
-2
votes
1 answer

Why would we use a pointer in an NSInteger but not in an NSNumber?

I have an NSInteger that doesn't use a pointer and an NSNumber that does use a pointer. Can someone explain to me why this is the case? All my teacher said was the NSInteger is being used as a type alias but I'm not familiar with that either…
-2
votes
2 answers

Objective C Arithmetic failing

I have a NSNumber and when I try to do basic arithmetic it fails. NSNumber *contentExpirationInDays = [NSNumber numberWithInt: 1]; When I try to do a basic multiplication to convert to seconds it gives me crazy numbers: NSTimeInterval…
agarcian
  • 3,909
  • 3
  • 33
  • 55
-2
votes
1 answer

__NSCFNumber return negative value

For some reason i cant set my NSNumber value. Code is simple: obj.objectId = [filteredArr[i] valueForKey:@"idx"]; Where [[filteredArr[i] valueForKey:@"idx"] class] is __NSCFNumber. It should be a number from 0 to 200.. but it is actually…
Evgeniy Kleban
  • 6,794
  • 13
  • 54
  • 107
-2
votes
1 answer

NSNumber convert to double issue - Swift

I have an array in obj-c with this data and latitude and longitude is a NSNumber [ [latitude]: 38.63180843974196 [longitude]: 33.12896232001408 [addressText]: address Name [isStartedPoint]: 1 ] and I am trying…
Luai Kalkatawi
  • 1,492
  • 5
  • 25
  • 51
-2
votes
2 answers

Finding the lowest NSInteger from NSArray

I am trying to return the lowest number in an array. Parameter: arrayOfNumbers - An array of NSNumbers. Return: The lowest number in the array as an NSInteger. The code I have thus far doesn't give me any errors, but does not pass the unit tests.…
ioskaveen
  • 196
  • 1
  • 4
  • 14
-2
votes
1 answer

If statement with NSNumber array

All I want to do is check if the NSNumbers at the given indexes in the array gameBoard add up to 3... I am new to Objective-C and I am unsure of all these NSNumbers... Can someone help me out? This is what I have.... I presume the == is not…
kpce
  • 35
  • 9
-2
votes
1 answer

adding 0 in front of nsnumber

I'm trying to save a month and the format needs to be 2 digits. The problem is the xcode is converting every month below October to 1 digit. How can I format the number so that it will be for example 01 for January? Edit saving as a nsnumber. This…
madgrand
  • 121
  • 1
  • 8