{"id":7832,"date":"2013-09-12T10:11:52","date_gmt":"2013-09-12T15:11:52","guid":{"rendered":"http:\/\/mjtsai.com\/blog\/?p=7832"},"modified":"2013-09-12T10:12:14","modified_gmt":"2013-09-12T15:12:14","slug":"formatting-nsinteger-and-nsuinteger","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2013\/09\/12\/formatting-nsinteger-and-nsuinteger\/","title":{"rendered":"Formatting NSInteger and NSUInteger"},"content":{"rendered":"<p><a href=\"https:\/\/twitter.com\/gparker\/status\/377910611453046784\">Greg Parker<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/gparker\/status\/377910611453046784\"><p><tt>%zd<\/tt>, <tt>%tu<\/tt>, <tt>%tx<\/tt> (signed, unsigned, hex) currently format <code>NSInteger<\/code> and <code>NSUInteger<\/code> with no warnings.<\/p><\/blockquote>\n<p>The <a href=\"https:\/\/developer.apple.com\/library\/mac\/documentation\/Darwin\/Reference\/ManPages\/man3\/printf.3.html\">printf(3) man page<\/a>:<\/p>\n<blockquote cite=\"https:\/\/developer.apple.com\/library\/mac\/documentation\/Darwin\/Reference\/ManPages\/man3\/printf.3.html\"><p>Note: the <tt>t<\/tt> modifier, when applied to a <tt>o<\/tt>, <tt>u<\/tt>, <tt>x<\/tt>, or <tt>X<\/tt> conversion, indicates that the argument is of an unsigned type equivalent in size to a <code>ptrdiff_t<\/code>. The <tt>z<\/tt> modifier, when applied to a <tt>d<\/tt> or <tt>i<\/tt> conversion, indicates that the argument is of a signed type equivalent in size to a <code>size_t<\/code>.<\/p><\/blockquote>\n<p>Apple&rsquo;s <a href=\"https:\/\/developer.apple.com\/library\/mac\/documentation\/Cocoa\/Conceptual\/Strings\/Articles\/formatSpecifiers.html\">String Format Specifiers<\/a> documentation still recommends casting to <code>long<\/code> or <code>unsigned long<\/code> and using <tt>%ld<\/tt> or <tt>%lu<\/tt>.<\/p>","protected":false},"excerpt":{"rendered":"<p>Greg Parker: %zd, %tu, %tx (signed, unsigned, hex) currently format NSInteger and NSUInteger with no warnings. The printf(3) man page: Note: the t modifier, when applied to a o, u, x, or X conversion, indicates that the argument is of an unsigned type equivalent in size to a ptrdiff_t. The z modifier, when applied to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"","apple_news_api_id":"","apple_news_api_modified_at":"","apple_news_api_revision":"","apple_news_api_share_url":"","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[4],"tags":[575,69,31,30,54,71],"class_list":["post-7832","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-64-bit","tag-cocoa","tag-ios","tag-mac","tag-objective-c","tag-programming"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/7832","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=7832"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/7832\/revisions"}],"predecessor-version":[{"id":7833,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/7832\/revisions\/7833"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=7832"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=7832"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=7832"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}