Video Tutorial: Objective-C Data Types: Integer

Ray Wenderlich


Your challenge is to add this code to your project, fill in the question marks, and answer the question:

// Fill in the question marks
uint32_t u32 = 4;
int16_t i16 = 5;
NSInteger nsInt = 6;

NSLog(@"uint32_t: %??? (%lu bytes): %??? to %???", u32, sizeof(u32), (int)???, (int)???);
NSLog(@"int16_t: %??? (%lu bytes): %??? to %???", i16, sizeof(i16), (short)???, (short)???);
NSLog(@"NSInteger: %??? (%lu bytes)", ???, sizeof(nsInt));

// Why is this incorrect on 64-bit architecture?
nsInt = 1000000000000000000;
int myInt = (int)nsInt;
NSLog(@"NSInteger: %ld", (long) nsInt);
NSLog(@"myInt: %d", myInt);

Download solution

Helpful links

Ray Wenderlich

Ray is part of a great team - the team, a group of over 100 developers and editors from across the world. He and the rest of the team are passionate both about making apps and teaching others the techniques to make them.

When Ray’s not programming, he’s probably playing video games, role playing games, or board games.

Other Items of Interest Weekly

Sign up to receive the latest tutorials from each week, and receive a free epic-length tutorial as a bonus!

Advertise with Us!

PragmaConf 2016 Come check out Alt U

Our Books

Our Team

Video Team

... 26 total!

iOS Team

... 80 total!

Android Team

... 35 total!

Unity Team

... 16 total!

Articles Team

... 4 total!

Resident Authors Team

... 29 total!

Podcast Team

... 7 total!

Recruitment Team

... 9 total!