July 10, 2009 9:14:45 AM PDT (one year ago). Seen 886 times.
Photo Giovambattista Fazioli
CTO
Saidmade Srl
Member since Jul 10, 2009
Posts: 11
Just another question,

What is better:

NSInteger value;

or

unsigned int value;

In iPhone develop is better use the wrap object like NSInteger or NSString that int or char?
July 10, 2009 9:32:14 AM PDT (one year ago)
Photo Jonathan Lehr
President
AboutObjects
Member since Mar 12, 2009
Location: South Riding
Posts: 22
NSInteger is a typedef for unsigned int, so there's really no difference. However it's conditionally compiled to be the same size on 32 and 64 bit platforms. Here's the actual declaration from NSObjCRuntime.h:
Code:

#if __LP64__ || (TARGET_OS_EMBEDDED && !TARGET_OS_IPHONE) || TARGET_OS_WIN32 || NS_BUILD_32_LIKE_64
typedef long NSInteger;
typedef unsigned long NSUInteger;
#else
typedef int NSInteger;
typedef unsigned int NSUInteger;
#endif

NSString is an entirely different matter. NSString is a powerful class in the Foundation framework. It's definitely worth some time to read through the reference material to learn more about how to work with NSString and its subclass, NSMutableString.

I'd highly recommend reading at least the first few sections of Strings Programming Guide for Cocoa, as well as skimming the API documentation for NSString and NSMutableString.

- Jonathan