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
73
votes
2 answers

What NSNumber (Integer 16, 32, 64) in Core Data should I use to keep NSUInteger

I want to keep NSUInteger into my core data and I don't know which type should I use (integer 16, 32, 64) to suit the space needed. From my understanding: Integer 16 can have minimum value of -32,768 to 32,767 Integer 32 can have minimum value of…
sarunw
  • 7,448
  • 10
  • 43
  • 76
36
votes
2 answers

Difference between int, NSInteger and NSUInteger

What is the main difference between int, NSInteger and NSUInteger in Objective-C? Which one is better to use in an application and why?
Hitarth
  • 1,836
  • 3
  • 26
  • 49
28
votes
4 answers

How do I convert NSUInteger value to int value in objectiveC?

How do I convert NSUInteger value to int value in objectiveC? and also how to print NSUInteger value in NSLog , I tried %@,%d,%lu these are not working and throwing Ex-Bad Access error. Thank you
GR.
  • 435
  • 1
  • 4
  • 18
25
votes
5 answers

How do you convert an NSUInteger into an NSString?

How do you convert an NSUInteger into an NSString? I've tried but my NSString returned 0 all the time. NSUInteger NamesCategoriesNSArrayCount = [self.NamesCategoriesNSArray count]; NSLog(@"--- %d", NamesCategoriesNSArrayCount); …
user563496
  • 261
  • 1
  • 3
  • 4
23
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,098
  • 22
  • 100
  • 190
14
votes
4 answers

NSString to NSUInteger

I've got a number in a NSString @"15". I want to convert this to NSUInteger, but I don't know how to do that...
dododedodonl
  • 4,427
  • 6
  • 28
  • 42
13
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
  • 106,283
  • 107
  • 420
  • 616
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
9
votes
1 answer

Why NSInteger instead of NSUInteger in "numberOfSectionInTableView:"?

The UITableView data source method numberOfSectionsInTableView: has a return type of NSInteger. However, a UITableView cannot have a negative amount of rows; it has 0 or greater rows, so why is the return type of NSInteger? Doesn't that allow for…
pasawaya
  • 11,364
  • 7
  • 50
  • 92
6
votes
3 answers

NSIntegerMax vs NSUIntegerMax

NSUInteger index = [self.objects indexOfObject:obj]; if (index == NSNotFound) { // Success! Note: NSNotFound internally uses NSIntegerMax } if (index == NSUIntegerMax) { // Fails! } Why? I'm suppose to get an unsigned value as a result of…
Mustafa
  • 20,108
  • 39
  • 139
  • 208
6
votes
1 answer

Using Multiple NSUInteger enums as a parameter to a method

I'm trying to make a method with a similar format to the setAutoresizingMask: method of NSView. I want to have someone be able to specify multiple values that i declared in my enum (NSHeightSizable | NSWidthSizable) like in autoresizing mask. How…
Alex Zielenski
  • 3,491
  • 1
  • 22
  • 42
6
votes
1 answer

Is there a better way to avoid 'Sign comparison' warning when comparing NSIndexPath's row and NSArray count?

I turned 'Signed Comparision' (aka -Wsign-compare) warnings for my iOS project in XCode (surprisingly, it was off by default). After that lots of warnings like this appeared: /Users/michalciuba/projects/GlobeMobile/Classes/ACMailController.m:86:19:…
Michał Ciuba
  • 7,611
  • 2
  • 29
  • 56
5
votes
1 answer

May I use NSCoder::encodeInteger:forKey: and decodeIntegerForKey: methods with argument of type NSUInteger?

I need to encode and decode property of type NSUInteger with NSCoder. Is it safe to use NSCoder::encodeInteger:forKey: and NSCoder::decodeIntegerForKey: methods for that? The other way around that comes to my mind is to wrap the unsigned integer…
Rasto
  • 17,000
  • 40
  • 141
  • 232
5
votes
2 answers

Implicit conversion loses integer precision: 'long long' to 'NSInteger' (aka 'int')

I am trying to assign a variable with type 'long long' to a type NSUInteger, What is the correct way to do that? my code line: expectedSize = response.expectedContentLength > 0 ? response.expectedContentLength : 0; where expectedSize is of type…
Firdous
  • 4,436
  • 12
  • 38
  • 76
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
  • 4,907
  • 8
  • 63
  • 124
1
2 3 4 5 6