What Are All of the Objective-C Primitive Types?

Status
Not open for further replies.
Joined
Jul 15, 2008
Messages
25
Reaction score
0
Points
1
I am working on an exercise in Objective-C to have a complete list of primitive types and to learn how large each primitive type is in Objective-C. I have the following code written. This code shows me the size of each primitive.

Am I missing any Objective-C primitives?

Code:
#import <Foundation/Foundation.h>

int main (int argc, const char * argv[]) {
	
	// calculate the sizes of C-Primitives
	int i = 1;
	NSLog(@"Primitive sizes:");
	NSLog(@"%d The size of a char is: %d.", i++, sizeof(char));
	NSLog(@"%d The size of short is: %d.", i++, sizeof(short));
	NSLog(@"%d The size of int is: %d.",  i++, sizeof(int));
	NSLog(@"%d The size of long is: %d.",  i++, sizeof(long));
	NSLog(@"%d The size of long long is: %d.",  i++, sizeof(long long));
	NSLog(@"%d The size of a unsigned char is: %d.",  i++, sizeof(unsigned char));
	NSLog(@"%d The size of unsigned short is: %d.",  i++, sizeof(unsigned short));
	NSLog(@"%d The size of unsigned int is: %d.",  i++, sizeof(unsigned int));
	NSLog(@"%d The size of unsigned long is: %d.",  i++, sizeof(unsigned long));
	NSLog(@"%d The size of unsigned long long is: %d.",  i++, sizeof(unsigned long long));
	NSLog(@"%d The size of a float is: %d.",  i++, sizeof(float));
	NSLog(@"%d The size of a double is %d.",  i++, sizeof(double));
	
	return 0;
}
 
Status
Not open for further replies.

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top