Home

NSUInteger

NSUInteger is an unsigned integer type used in Apple's Cocoa and Cocoa Touch frameworks. It is the standard type for representing counts, lengths, and indices in APIs such as NSArray, NSString, NSData, and NSRange. The exact size of NSUInteger depends on the platform: it is 32 bits on 32-bit environments and 64 bits on 64-bit environments.

In Apple's headers, NSUInteger is typically defined as an unsigned long (typedef unsigned long NSUInteger). Because

Many APIs use NSUInteger for return values that indicate positions or lengths. A common sentinel value in

In Swift, NSUInteger is imported as UInt, reflecting the same unsigned, platform-dependent size semantics. When writing

See also: NSInteger, NSNotFound, NSUInteger constant, and API guidelines for counts and indices.

its
size
follows
the
platform’s
pointer
width,
code
that
uses
NSUInteger
can
scale
naturally
between
32-
and
64-bit
targets.
As
an
unsigned
type,
it
cannot
represent
negative
values,
which
makes
it
suitable
for
counts
and
array
indices
where
negative
numbers
would
be
invalid.
such
contexts
is
NSNotFound,
which
is
used
to
indicate
“not
found”
or
an
invalid
index;
NSNotFound
is
defined
as
a
large
integer
(NSIntegerMax)
and
can
be
assigned
to
or
compared
with
an
NSUInteger
when
appropriate.
Swift
code,
developers
often
prefer
the
native
Int
or
UInt
types
for
clarity,
but
bridging
with
Objective-C
APIs
that
use
NSUInteger
remains
seamless.