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

Are there any issues with int32_t to NSInteger casting?

I am creating a bitmask for the iOS using the data type int32_t. This is then set to a variable that accepts an NSInteger. This throws no compile time errors as expected, but I was wondering - is there was some way that this could cause run-time…
AndrewKS
  • 3,603
  • 2
  • 24
  • 33
4
votes
1 answer

iOS : NSInteger and NSUInteger comparison

Surprise! I've a variable like this, NSInteger index = 0; I'm comparing it with one of subviews count (which returns NSUInteger) like this, if((index-1) <= [[currentmonth subviews] count]) { NSLog(@"true"); } else { …
Hemang
  • 26,840
  • 19
  • 119
  • 186
4
votes
3 answers

is NSInteger a 32bit integer

Am I correct in thinking that declaring a NSInteger in an ios environment means it will only ever be a 32bit value? I would like to know as I have been told by another programmer not familiar with objective c to use a int32, the only similar thing I…
HurkNburkS
  • 5,492
  • 19
  • 100
  • 183
3
votes
2 answers

Objective-C int is bridged as Int32 to Swift

If I'm correct, Objective-C's int type length depends on the platform word length (i.e. it's 64 bit when running in a 64-bit environment and 32-bit when running in a 32-bit environment). However, when bridging an Objective-C interface to Swift, this…
Richard Topchii
  • 7,075
  • 8
  • 48
  • 115
3
votes
5 answers

iPhone - numberOfRowsInSection error with array count

I am getting the following error if the @"Comments" array is 0 and the other two are 1 or greater. *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSMutableArray objectAtIndex:]: index 0 beyond bounds for empty…
gotnull
  • 26,454
  • 22
  • 137
  • 203
3
votes
3 answers

Does NSUserDefault take a few seconds to register the values I pass it?

I am passing an integer value to the NSUserDefault object to store for use when my app loads up. I HAD it working perfectly until I tried to switch that integer value to a float. It caused a whole bunch of problems, so I re-adjusted my approach, and…
Jerry
  • 537
  • 1
  • 9
  • 16
3
votes
1 answer

Objective-C can't assign a NSInteger to an NSInteger variable?

This is going to seem like a really silly question but I can't figure out why I'm getting an error. I have an instance variable declared as: NSInteger *scopeSelected; I'm using this variable to keep track of what scope has been selected in a…
dpigera
  • 3,339
  • 5
  • 39
  • 60
3
votes
1 answer

Handling integers in Objective-C

I was told by a developer that working with integers can be frustrating in Objective-C, so that he prefers to work directly with strings for IDs returned in JSON messages in order to save frequent conversions between integers and strings. In other…
skyork
  • 7,113
  • 18
  • 63
  • 103
3
votes
3 answers

How to limit characters in UITextView iOS

I have a UITextView and i would like to limit the number of characters a user can input. i have also tried to display a warning if the textfield is empty but to no luck. textview.h @property (nonatomic,strong) IBOutlet UITextView…
smithyy
  • 220
  • 2
  • 12
3
votes
2 answers

What is the equivalent of NSNotFound for floats

What if I have a method that returns a CGFloat and that method could not find an expected number, I would like to return something like NSNotFound, but that is an NSInteger. Whats the best practice for this ?
bobmoff
  • 2,415
  • 3
  • 25
  • 32
3
votes
1 answer

Pass integer in userInfo of NSTimer

I'm trying to pass an integer (testInt) through the userInfo field of NSTimer timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(count:) userInfo:testInt repeats:YES]; However I'm getting an incompatible types error…
thefan12345
  • 136
  • 16
3
votes
3 answers

Why am I getting strange garbage with NSInteger and arc4random?

I'm trying to get a random number using arc4random between -60 and 60. I generate avnumber between 1 and 120 inclusively, and then subtract 60. If this is in one line, I get weird results whenever the number is negative. //Loop illustrates point…
Eliza Wilson
  • 1,031
  • 1
  • 13
  • 38
3
votes
1 answer

NSInteger versus int

What would be the reason to use an NSInteger vs an int in iPhone programming? Thanks.
Crystal
  • 28,460
  • 62
  • 219
  • 393
3
votes
1 answer

What is the default value of an NSUInteger in local scope?

Given the following snippet: - (void)doSomething { NSUInteger count; } What is count? Is it guaranteed to be 0?
funroll
  • 35,925
  • 7
  • 54
  • 59
3
votes
3 answers

valueForKey only returns memory address and not actually value

NSDictionary *topic = [spaces objectAtIndex:i]; NSInteger topicid = [topic valueForKey:@"TOPICID"]; when I run this and print out topic I get the following: Printing description of topic: {type = mutable,…
Jason
  • 17,276
  • 23
  • 73
  • 114