Questions tagged [nsuinteger]

An Objective-C unsigned integer

An Objective-C unsigned integer

typedef unsigned long NSUInteger;

Reference: https://developer.apple.com/Library/ios/documentation/Cocoa/Reference/Foundation/Miscellaneous/Foundation_DataTypes/index.html#//apple_ref/c/tdef/NSUInteger

83 questions
4
votes
1 answer

Handling 64 bit integers on a 32 bit iPhone

I would like to handle 64 bit unsigned integers on a iPhone 4s (which of course has a 32 bit ARM 6 processor). When trying to work with 64 bit unsigned integers, e.g. Twitter IDs, I have the following problem: // Array holding the 64 bit integer IDs…
AlexR
  • 5,514
  • 9
  • 75
  • 130
3
votes
1 answer

Convert NSUInteger to string with ARC

I'm trying to cast a NSUInteger to a string so I can print a message. From searching, it seems like I need to use stringWithFormat, but I am getting an error that an implicit cast not allowed with ARC. Here's the line in question: NSString *text =…
tangobango
  • 381
  • 1
  • 4
  • 17
3
votes
2 answers

Add NSUInteger to NSMutableArray

Hello I am working on a project and I am trying to add an NSUInteger to an NSMutableArray. I am new to Objective-C and C in general. When I run the app NSLog displays null. I'd appreciate any help anyone is able to provide. Here is my…
demuro1
  • 289
  • 1
  • 4
  • 15
3
votes
1 answer

Changing Parameter Type for Delegate Methods

I have a NSURL delegate method which takes in NSInteger as the parameter - (void)connection:(NSURLConnection *)connection didSendBodyData:(NSInteger)bytesWritten totalBytesWritten:(NSInteger)totalBytesWritten…
user1861763
  • 135
  • 11
3
votes
5 answers

Value of NSUInteger and NaN?

Why is the value of NSUInteger 2^32 - 1 instead of 2^32? Is there a relationship between this fact and the need of a nan value? This is so confusing.
Lluís
  • 578
  • 1
  • 5
  • 10
2
votes
1 answer

NSUInteger to int

I wrote a method tha uses myarray, defined in the same class. When I use count it always returns 0. When I use: printf("%d", [myarray count]); compiler says: Format '%d' expetcs type 'int', but argument 2 has type 'NSUInteger' why?
thepepp
  • 304
  • 1
  • 3
  • 15
2
votes
1 answer

NSNumber with 0 convert to NSInteger/NSUInteger become nil

Why NSNumber of 0 cannot be converted to correct NSInteger/NSUInteger value? NSUInteger a = [@0 unsignedIntegerValue]; // a become nil Why is a in the above line of code nil. Shouldn't it be equal to 0? In the console: (lldb) po [@0…
Alston
  • 1,166
  • 2
  • 13
  • 26
1
vote
2 answers

Allocating a NSUInteger IndexBuffer

I am trying to retrieve my NSIndexSet by calling -getIndexes:maxCount:indexRange Here is my code const NSUInteger arrayCount = picturesArray.count; NSUInteger theIndexBuffer[arrayCount]; [picturesArray getIndexes:theIndexBuffer…
user82383
  • 879
  • 3
  • 11
  • 31
1
vote
1 answer

Retrieving an integer value from a sqlite3 db (problem in obj-c)

In a sqlite3 database, I've a table "data" with two fields: type and path. The field type is defined as INTEGER. In this field I insert a NSUInteger value (which will be for example 0 or 1). The problem is that, when I retrieve it, I obtain a…
Sefran
  • 375
  • 6
  • 24
1
vote
4 answers

Determine if NSUInteger has a value or is nil

I'm trying to use a HKAnchoredObjectQuery on iOS. To do so I have to provide an anchor to the query which in this case is a NSUInteger. I want to save this integer for queries in the future in the NSUserDefaults and just simply want to use if(anchor…
Constantin Jacob
  • 488
  • 1
  • 8
  • 21
1
vote
1 answer

When adding 1 to NSUInteger result is multiples of 8

I have a NSUInteger. In the viedDidLoad method I set it so 0 : @property NSUInteger *unitOne; //In viewdidload _unitOne = 0; This adds one to it. (This is in touchesBegan method. This code only takes place when a UIImageView is clicked. The…
Minestrone-Soup
  • 399
  • 1
  • 16
1
vote
1 answer

How do I increment a NSUInteger variable?

NSUInteger wordInt = sentence.length; I want to add 1 like this -> wordInt = wordInt + 1 ; But It doesn't work. I don't know.... Please!!
Beomseok
  • 471
  • 1
  • 6
  • 22
1
vote
2 answers

Divide NSUInteger by 100

I have an NSUInteger and i want to divide it by 100. So lets say i have the number 1 in an NSUInteger i want to divide it by 100 and get 0.01 as the result. (float) percent / 100 percent is an NSUInteger
Cristian
  • 61
  • 8
0
votes
1 answer

Ramifications of returning an unsigned long when unsigned int is expected

I'm implementing the -hash method on a class, which is supposed to return an NSUInteger. My implementation for it was going to be similar to this: - (NSUInteger) hash { return CFHash(self->cfObj); } Now, CFHash returns a CFHashCode, which is a…
dark_perfect
  • 1,458
  • 1
  • 23
  • 41
0
votes
1 answer

Division and NSUInteger

I have some calculation that involves negative values: row = (stagePosition - col) / PHNumRow; Say stagePosition is -7 and col is 1. They are both NSInteger, including row. PHNumRow is 8. If PHNumRow is NSInteger, I get the result I expect: -1. But…
hyn
  • 473
  • 7
  • 20