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
7
votes
4 answers

How to tell Core Data's NSNumber property's type

I have an iOS 4 project using Core Data. When I design the Core Data Model, the attributes have Integer 64, Integer 32, Integer 16, Decimal, Double, Float, and Boolean. But in the generated NSManagedObject subclasses, they are all NSNumber*. So…
Zhao Xiang
  • 1,625
  • 2
  • 23
  • 40
7
votes
1 answer

Is it possible to replicate Swifts automatic numeric value bridging to Foundation (NSNumber) for (U)Int8/16/32/64 types?

Question Is it possible to replicate Swifts numeric value bridging to Foundation:s NSNumber reference type, for e.g. Int32, UInt32, Int64 and UInt64 types? Specifically, replicating the automatic by-assignment bridging covered below. Intended…
dfrib
  • 70,367
  • 12
  • 127
  • 192
7
votes
2 answers

find all numbers in a string with a NSScanner

I used the below code to extract numbers from inputString using NSScanner NSString *inputString = @"Dhoni7 notout at183*runs in 145andhehit15four's and10sixers100"; NSString *numberString; NSArray *elements = [inputString…
Manju Basha
  • 665
  • 1
  • 9
  • 29
7
votes
3 answers

how to convert arabic number to english number

I could convert English numbers to Arabic numbers in Xcode. but now I want to convert Arabic/Persian numbers to English numbers in iOS ... Please guide me about this... This is my code for conversion (English to Arabic) : -…
MmD
  • 2,044
  • 5
  • 22
  • 41
7
votes
1 answer

How to read crash log? How to find why the app crashes in system library? What means EXC_CRASH (SIGABRT)?

I got an crash logs from a customer to figure why my app crash on her iPhone. Here some info from crash log: Exception Type: EXC_CRASH (SIGABRT) Exception Codes: 0x00000000, 0x00000000 Crashed Thread: 0 Stack trace for Thread 0 Thread 0…
Aleksejs Mjaliks
  • 8,647
  • 6
  • 38
  • 44
7
votes
2 answers

Why NSNumber literals cannot be used in static declarations

I'm declaring: static NSString *a = @"a"; and this is a correct declaration in iOS6 (it should be more correct to use the compiler version but I do not know it at the moment). I thought that with number literals also: static NSNumber *b=@1; could…
giampaolo
  • 6,906
  • 5
  • 45
  • 73
6
votes
3 answers

How is it possible to pass NSNumber to a method expecting a bool?

[[self.view.window subviews] makeObjectsPerformSelector:@selector(setUserInteractionEnabled:) withObject:[NSNumber numberWithBool:NO]]; I saw this code in another question's answer ( How to disable touch input to all views except the top-most…
Jonathan.
  • 53,997
  • 54
  • 186
  • 290
6
votes
4 answers

NSSet of NSNumbers - member method is always nil

I want to have a simple NSSet which is loaded with some NSNumbers and then find out if those numbers are already added in the set or not. When I do this: NSMutableSet *set = [[NSMutableSet alloc] init]; NSNumber *num1 = [NSNumber…
haluzak
  • 1,133
  • 3
  • 17
  • 31
6
votes
4 answers

NSNumber stored in NSUserDefaults

Something weird just happened. I stored a NSNumber with an unsigned long long value in NSUserDefaults. When I retrieve it, the value just changed. It seems that system thinks the number is long long instead of unsigned long long. What's worse is…
Swordsfrog
  • 119
  • 2
  • 3
  • 8
6
votes
1 answer

argument isKindOfClass: [NSNumber class] - sane way to check this?

So I was playing with something where the class type of the arg is unknown until runtime. like this: - (NSNumber *)doWhatever:(id)arg { // this ALWAYS FAILS if ([arg isKindOfClass:[NSNumber class]]) { return arg; } else { …
jpswain
  • 14,642
  • 8
  • 58
  • 63
6
votes
3 answers

local image is being returned as an integer - React Native

I'm trying to display a local image in my react native app. The docs say the way that you do this is by doing something like ; This works on its own, however I'm trying to pass this in as conditional…
L-R
  • 418
  • 1
  • 7
  • 23
6
votes
1 answer

issue with NSNumber in swift 3

I have converted my project to swift 3, and I have a problem with NSNumber that I cannot deal with. Here's my number formatter declaration let numberFormatter: NumberFormatter = { let nf = NumberFormatter() nf.numberStyle = .decimal …
belab
  • 117
  • 3
  • 12
6
votes
2 answers

Conversion between CGFloat and NSNumber without unnecessary promotion to Double

As we all know, CGFloat (which is ubiquitous in CoreGraphics, UIKit etc) can be a 32-bit or 64-bit floating point number, depending on the processor architecture. In C, CGFloat it is a typealias to float or double, in Swift is it defined as a struct…
Martin R
  • 529,903
  • 94
  • 1,240
  • 1,382
6
votes
4 answers

Swift: NSNumber is not a subtype of UIViewAnimationCurve

How do I get the line below to compile? UIView.setAnimationCurve(userInfo[UIKeyboardAnimationCurveUserInfoKey].integerValue) Right now, it gives the compile error: 'NSNumber' is not a subtype of 'UIViewAnimationCurve' Why does the compiler think…
ma11hew28
  • 121,420
  • 116
  • 450
  • 651
6
votes
3 answers

How to do multiplication and addition with NSNumber

I want to implement simple calculation with NSNumber. For ex: int a; a=a*10; a=a+1; NSLog(@"%d",a); How to do the same thing if i declare NSNumber *a; I want to implement the same logic with NSNumber which I implemented using integer. Thanks
user3575678
  • 115
  • 1
  • 9