nsnumber Questions
28
Solved
How can I convert all numbers that are more than 3 digits down to a 4 digit or less number?
This is exactly what I mean:
10345 = 10.3k
10012 = 10k
123546 = 123.5k
4384324 = 4.3m
Rounding is not...
Jacklighter asked 16/8, 2013 at 6:37
2
Solved
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 wit...
Juno asked 13/12, 2012 at 23:12
7
Solved
Why is NSNumber immutable? Was there a good reason? Because now I am thinking about creating my own class just for the sake of mutability.
Madson asked 28/4, 2011 at 13:28
3
Solved
After successfully acquiring a picture from the iPhone camera on iOS 4.1, you can use the key
@"UIImagePickerControllerMediaMetadata"
to return information about the picture. One of the keys in...
7
Solved
I don't understand how NSNumberFormatterPercentStyle works!
Example:
NSNumber *number = [NSNumber numberWithFloat:90.5];
NSNumberFormatter *percentageFormatter = [[[NSNumberFormatter alloc] init]...
Preoccupation asked 11/8, 2010 at 15:53
5
Solved
If I do the following in Objective-C:
NSString *result = [NSString stringWithFormat:@"%1.1f", -0.01];
It will give result @"-0.0"
Does anybody know how I can force a result @"0.0" (without the ...
Crockett asked 10/6, 2012 at 14:15
4
Solved
I am trying to format a NSNumber containing a value of 0.305 as "30.5%".
However, my following code does not work:
[numberFormatter setNumberStyle:NSNumberFormatterPercentStyle];
[numberFormatte...
Angiosperm asked 24/2, 2012 at 15:34
5
Solved
I am a beginner at Objective-C and I am a bit confused at this scenario. I have the following code:
if (number1 < number2) {
NSLog(@"THE FOLLOWING NUMBER ");
NSLog(@"%@", number1);
NSLog(@"I...
Nasa asked 7/7, 2011 at 2:42
2
Solved
I have a UInt16 variable that I would like to pass to a legacy function that requires an NSNumber.
If I try:
var castAsNSNumber : NSNumber = myUInt16
I get a compiler error 'UInt16' is not conv...
5
Consider this code:
NSNumber* interchangeId = dict[@"interchangeMarkerLogId"];
long long llValue = [interchangeId longLongValue];
double dValue = [interchangeId doubleValue];
NSNumber* doubleId = ...
Alfilaria asked 25/11, 2013 at 16:26
9
Solved
I found a method to convert String to NSNumber, but the code is in Objective-C. I have tried converting it to Swift but it is not working.
The code I am using:
NSNumberFormatter *f = [[NSNumberForm...
5
Solved
What would be the shortest/cleanest way to convert an Optional Number to an Optional Int in Swift?
Is there a better way than this? (see below)
let orderNumberInt : Int?
if event.orderNum != nil...
Bonds asked 1/12, 2015 at 3:33
5
Solved
I use [NSNumber numberWithInt:42] or @(42) to convert an int to NSNumber before adding it to an NSDictionary:
int intValue = 42;
NSNumber *numberValue = [NSNumber numberWithInt:intValue];
NSDictio...
Hammertoe asked 24/8, 2010 at 11:25
5
Solved
4
How to convert an Array of NSNumber to Array of String in order to display the value in UITableView?
cell.textlabel.text = ?
Code:
var a = [68.208983, 6.373902, 1.34085, 3.974012, 110.484001,
...
2
Solved
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...
5
Solved
I am trying to convert my project to Swift 3.0 however I am having two error messages when working with NSNumber and Integers.
Cannot assign type int to type NSNumber
for
//item is a NSMana...
6
Solved
Now this must be easy, but how can sum two NSNumber? Is like:
[one floatValue] + [two floatValue]
or exist a better way?
Aladdin asked 29/1, 2009 at 23:54
6
Solved
I have a NSMutableArray of NSNumbers. Basically I just want to check if any of the NSNumbers in the array = some value.
I could iterate through the array, checking one by one, by this is by no me...
Ancy asked 7/8, 2011 at 6:47
4
Solved
I'm trying to do some number comparisons and I'm getting some weird results.
NSNumber* number1 = [NSNumber numberWithFloat:1.004];
NSNumber* number2 = [NSNumber numberWithDouble:1.004];
([number1...
Antibiotic asked 9/2, 2012 at 22:33
5
Solved
Below is part of my react component. I have a props named daysUntil coming into this component which contains a number. In this example it is being pass the number 0 which results in the fontWeight...
Healthful asked 25/2, 2016 at 23:16
3
Solved
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
<Image source={require('./my-icon.png')} />;
This works on its...
Catechism asked 25/4, 2018 at 13:15
5
I am confused by NSDecimalNumber and its "behaviors". I have an NSDecimalNumber that represents a dollar value, say $37.50. I'd like to find out how many times say 5.0 goes into that number and the...
Garry asked 24/7, 2009 at 3:20
12
I want to get the type of NSNumber instance.
I found out on http://www.cocoadev.com/index.pl?NSNumber this:
NSNumber *myNum = [[NSNumber alloc] initWithBool:TRUE];
if ([[myNum className] isEq...
Earlie asked 25/3, 2010 at 19:34
18
Solved
How can I convert a NSString containing a number of any primitive data type (e.g. int, float, char, unsigned int, etc.)? The problem is, I don't know which number type the string will contain at ru...
Livi asked 19/9, 2009 at 15:48
1 Next >
© 2022 - 2024 — McMap. All rights reserved.