• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
What is the default type for an integer literal (as relates to its use in NSLog)?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

What is the default type for an integer literal (as relates to its use in NSLog)?


  • Subject: What is the default type for an integer literal (as relates to its use in NSLog)?
  • From: Stuart Malin <email@hidden>
  • Date: Mon, 15 Dec 2008 09:35:20 -1000

I am trying to be 32/64 bit "clean" in some new code that I am writing. When I declare some integer values, say for named option values as shown here, what is the type that the compiler assigns to these values?

enum {
	SomeOptionValue     = 1,
	AnotherOptionValue  = 2,
};

The type matters to the construction of an NSLog statement. If the type is NSInteger, then it seems the best way (for 32/64 bit compatibility) to display its value is:

NSLog(@"SomeOptionValue = %ld", (long) SomeOptionValue);

Or so I conclude from reading:
[1] String Format Specifiers
http://developer.apple.com/documentation/Cocoa/Conceptual/Strings/Articles/formatSpecifiers.html

[2] 64-Bit Transition Guide: Type Specifiers
http://developer.apple.com/documentation/Cocoa/Conceptual/Cocoa64BitGuide/ConvertingExistingApp/chapter_4_section_3.html

Separately, from a space efficiency perspective, would it be better in the case of having a small set of option values to force the type to be an unsigned int? That is, if I have a method that takes such an option, which of the following method signatures is nowadays preferred?

- (void) someMethodWithOption:(unsigned int)optionValue;

- (void) someMethodWithOption:(NSInteger)optionValue;






_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: What is the default type for an integer literal (as relates to its use in NSLog)?
      • From: Nick Zitzmann <email@hidden>
    • Re: What is the default type for an integer literal (as relates to its use in NSLog)?
      • From: "Michael Ash" <email@hidden>
  • Prev by Date: Re: NSOutline : NSTableViewSelectionHighlightStyleSourceList
  • Next by Date: Re: View Swapping
  • Previous by thread: Manual Core Data schema migration in -[NSPersistentDocument configurePersistentStoreCoordinatorForURL:ofType:...] without "document changed" error?
  • Next by thread: Re: What is the default type for an integer literal (as relates to its use in NSLog)?
  • Index(es):
    • Date
    • Thread