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
-2
votes
1 answer

Objective C: Using a BOOL to return 'YES' if a condition can be applied

Hi there I have some code at the moment that gives me the error ("0") is not equal to ("50") - condition not applied correctly Basically I am currently using a traditional for loop within a BOOL which goes through the list of items and checks…
Jim
  • 1
  • 2
-2
votes
1 answer

converting NSString to NSInteger in iOS

I have a string as NSString *milliSeconds=@"1413808458821"; I tried the following to convert it to number, but None of them are giving correct value. NSInteger number = [milliSeconds intValue]; NSInteger number = [milliSeconds…
Ashok
  • 5,585
  • 5
  • 52
  • 80
-2
votes
1 answer

Imprecision in floating point numbers

If I create an NSNumber with a double value of 0.085, it seems extra precision gets added to the number. However, this isn't the case with 0.85. I don't understand why this is the case, but I'm sure there's a really obvious answer. Does anyone know…
Ian
  • 7,480
  • 2
  • 47
  • 51
-2
votes
2 answers

How to convert elements of NSMutableArray (NString) to NSNumber and add them up?

Ok so I have NsMutable array with Strings which are in format: 32,45,54,5550 etc. What is the easiest way to convert all these strings to nsnumber and also get the sum of entire array.
James Douglas
  • 736
  • 1
  • 11
  • 20
-2
votes
1 answer

If statement not working with NSNumber?

I'm new to coding and can't find an accurate answer anywhere. I'm trying to make the NSNumber return false if the BOOL is true. Any help? Thanks static BOOL someBOOL; %hook (class I want to hook) -(void)sampleMethod:(NSNumber *)boolNumber { …
Andrew68
  • 1
  • 1
-2
votes
1 answer

Both if and else statement called randomly

I have a method which parses HTML. In there there is an if/else statement: if ((NSNumber1 == NSNumber2)) { NSLog(@"dafuq1?"); } else { NSLog(@"dafuq2?"); } The log is sometimes like this: ...:dafuq1? ...:dafuq2? So both parts are called.…
gallileo
  • 462
  • 5
  • 21
-2
votes
1 answer

value get released from variable when value is float number

I am facing such strange issue right now, I am trying to implement calculator in my project the demo. The place I want to implement is ARC enable and my project ARC disable everything is working perfectly in that demo its working perfect in my…
Prakash Desai
  • 511
  • 3
  • 14
-2
votes
1 answer

converting nsinteger to nsnumber strange number

I have a method that receives an nsinteger, then I need to convert it to a nsnumber, but I get a really strange number, my code is: +(TarefaMR *)GetTask:(NSInteger *)idTask { NSLog(@"idTask %@",[NSNumber numberWithInteger:idTask]); …
edounl
  • 65
  • 1
  • 11
-2
votes
2 answers

Memory management for classes like NSNumber, NSSet

These are classes and they declares pointers... to objects right? You send methods to them like objects. NSNumber * myNumber = [NSNumber numberWithInteger: x]; So why are they not released like so: [myNumber release]; Thanks!
-2
votes
2 answers

Colours within a NSArray arrayWithObjects

I have a simple leader boards table for an iphone game that allows me to view the previous high scores however the background is black and therefore it is not visible. I am using the code: [highscores addObject:[NSArray…
user1432813
  • 162
  • 2
  • 10
-3
votes
3 answers

In a string with just numbers and commas how do I convert that into a double

So I have a string with just numbers and commas. for example "1,233,323.32"(String) but I want to convert that to 1233323.32(double).
Bhavin p
  • 98
  • 10
-3
votes
1 answer

Absorb value from NSNumber

let Rating = self.currentPerson.Rating // This is a NSNumber Rating -= 1 What I'm trying to do, is to take an x value from the Rating, and then print the new value of Rating. How do I do this properly?
Victor
  • 1,603
  • 4
  • 17
  • 24
-3
votes
4 answers

i get data in meter in nsnumber from api but how will i convert it into km

my code is below NSNumber *someNumber = [[_dict2 objectForKey:@"location"] objectForKey:@"distance"]; NSString *someString = [someNumber stringValue]; _lbldistance.text=someString;
-3
votes
4 answers

Comparing data from NSNumber CoreData iOS

I've got in CoreData a @property (nonatomic, retain) NSNumber * hidden; which is Boolean. I am trying using following code [object valueForKey:@"hidden"] How can I compare the returned value, to use it in if() if ([[object valueForKey:@"hidden"]…
David
  • 5
  • 4
-3
votes
2 answers

Passing a NSNumber from one method to another

I'll just show the example it's easier than words. .h file @interface Something : UITableViewController { NSNumber *myNumber; } .m file -(void) someMethod1 { NSLog @("is it reaching here? %@",…
1 2 3
52
53