Questions tagged [nsinteger]

An NSInteger is a data type in Objective-C. It is used to describe an integer.

An NSInteger is data type in Objective-C used to describe an integer. When building 32-bit applications, NSInteger is a 32-bit integer. A 64-bit application treats NSInteger as a 64-bit integer.

258 questions
25
votes
1 answer

Converting int to NSInteger

Possible Duplicate: How to convert An NSInteger to an int? I am new to iOS programming, how do I convert int to NSInteger. I have found references on how to convert NSInteger to NSNumber but I wasn't able to figure it out. Any help would be…
Bala
  • 2,895
  • 1
  • 19
  • 60
25
votes
4 answers

Convert NSInteger to NSUInteger?

I am trying to convert a NSInteger to a NSUInteger and I googled it and found no real answer. How would I do this?
SimplyKiwi
  • 12,376
  • 22
  • 105
  • 191
21
votes
4 answers

Benefits of using NSInteger over int?

I am trying to comprehend how development is affected when developing for both 32-bit and 64-bit architectures. From what I have researched thus far, I understand an int is always 4 bytes regardless of the architecture of the device running the app.…
Jordan H
  • 52,571
  • 37
  • 201
  • 351
18
votes
6 answers

How to evaluate the string equation in ios

Is there way to solve the string equations in ios ? For example Input: NSString * str =@"1+2"; Output: NSInteger result = 3 // i.e sum of 1+2 from str How to go about this and get expected result! Please help!
Vinayak Kini
  • 2,919
  • 21
  • 35
17
votes
1 answer

C/Objective-C read and get last digit of integer?

How can i get the last digit of an integer (or NSInteger) outputted to integer? example: int time = CFAbsoluteGetCurrent(); int lastDigit;
Daniel Node.js
  • 6,734
  • 9
  • 35
  • 57
15
votes
7 answers

casting NSInteger into NSString

I'm trying to make one string out of several different parts. This below is what i have right now. I don't get any errors in my code but as soon as i run this and do the event that triggers it i get EXC_BAD_ACCESS. Is there another way of casting…
user1213042
15
votes
2 answers

How to convert typedef enum to NSNumber?

Is each value of a typedef enum treated as an int? E.g., given the following typedef enum: // UIView.h typedef enum { UIViewAnimationCurveEaseInOut, UIViewAnimationCurveEaseIn, UIViewAnimationCurveEaseOut, …
ma11hew28
  • 121,420
  • 116
  • 450
  • 651
14
votes
2 answers

What is the difference between int and NSInteger?

Possible Duplicates: When to use NSInteger vs int? Why is there is an NSInteger? Can we use int and NSInteger interchangably? Is there any specific situation to use NSInteger only, instead of using int?
Prasad
  • 1,904
  • 4
  • 19
  • 24
14
votes
4 answers

Int or NSInteger as object for method argument. Objective-C

I'm having some trouble passing a number as an argument for a method: - (void)meth2:(int)next_int; And to call that method I need this: int next_int = 1; [self performSelectorOnMainThread:@selector(meth2:) withObject:next_int…
sergiobuj
  • 2,318
  • 2
  • 21
  • 24
12
votes
3 answers

Why doesn't cocoa use the same enum declaration style everywhere?

I was wondering what is the rationale behind different styles of enum declaration on cocoa? Like this: enum { constants.. }; typedef NSUInteger sometype; Is the reason to use typedef to get assigments to NSUInteger to work without casting?…
Simo Salminen
  • 2,306
  • 2
  • 14
  • 11
10
votes
4 answers

Check if Integer is Positive or Negative - Objective C

How can I tell in objective-c coding if an integer is positive or negative. I'm doing this so that I can write an "if" statement stating that if this integer is positive then do this, and if its negative do this. Thanks, Kevin
lab12
  • 6,400
  • 21
  • 68
  • 106
9
votes
5 answers

Is NSNumber overkill for an instance-level counter?

I'm new to Objective-C and Cocoa. I've read that NSInteger and NSNumber are preferred when working with simple integers because they're the "platform-safe" versions of the primitive numeric types (and in NSNumber's case, wrapped in an object). So,…
Rich
  • 36,270
  • 31
  • 115
  • 154
9
votes
1 answer

Implicit Conversion from NSInteger to NSString not allowed in ARC.. what workaround should be used to deal with Integers

This is my code in my viewcontroller.m file - (void)viewDidLoad{ [super viewDidLoad]; [self.abilitygeneration setText:((TestAbility *)[self.testabilities objectAtIndex:0]).abilitygeneration]; } It gives me an error implicit conversion of NSInteger…
Pang Zi Yang
  • 95
  • 1
  • 1
  • 5
8
votes
4 answers

How to compare two NSInteger?

How do we compare two NSInteger numbers ? I have two NSIntegers and comparing them the regular way wasnt working. if (NSIntegerNumber1 >= NSIntegerNumber2) { //do something } Eventhough, the first value was 13 and the second value was 17, the…
Ahsan
  • 2,964
  • 11
  • 53
  • 96
8
votes
1 answer

How to convert NSIndexPath to NSInteger?

I have searched and found a previous answer for this question here. The problem is that the answer marked as a solution does not work. Inside my tableView:didSelectRowAtIndexPath: method, I have NSInteger *currentRow = indexPath.row; and it…
tarheel
  • 4,727
  • 9
  • 39
  • 52
1
2
3
17 18