Home

objCType

objCType is a method of the NSValue class in Objective-C that returns the Objective-C type encoding for the value stored in the NSValue instance. The return value is a C string (const char *) describing the type, using the same encoding syntax used by the Objective-C runtime.

The type encoding returned by objCType follows the standard Objective-C runtime type encodings. Simple primitive types

Usage typically involves inspecting the encoding to determine how to interpret the raw bytes stored in the

Related concepts include the runtime type encodings used by the Objective-C runtime and the @encode directive,

have
single-letter
codes,
such
as
i
for
int,
d
for
double,
c
for
char,
and
f
for
float.
Object
types
use
@,
and
pointers
are
indicated
with
a
leading
^.
Structs
and
unions
are
encoded
with
braces
and
their
field
encodings,
for
example,
"{CGPoint=dd}"
for
a
CGPoint.
The
encoding
can
also
represent
more
complex
types,
including
arrays,
unions,
and
nested
structs,
using
the
established
encoding
rules
or
the
@encode
directive.
NSValue,
or
when
constructing
an
NSValue
from
raw
memory
with
valueWithBytes:objCType:.
Developers
often
compare
the
result
of
objCType
with
known
encodings
(such
as
@encode(type))
to
handle
values
generically
or
to
bridge
between
Objective-C
and
C
APIs.
The
method
is
commonly
used
in
conjunction
with
other
NSValue
facilities,
such
as
getValue:
to
extract
the
stored
data
or
valueWithBytes:objCType:
to
create
values
from
raw
memory.
which
provides
the
type
encoding
string
for
a
given
C
or
Objective-C
type.
objCType
is
part
of
the
NSValue
interface
for
working
with
arbitrary
binary
data
in
a
typed
way.