0
votes

I get few warnings in this Xcode 5.1 beta 5 when i installed this new Xcode.

Values of type NSInteger should not be used as format arguments; add an explicit cast to long instead

NSString *time;

NSInteger hour;

time =  [@"" stringByAppendingString:[NSString stringWithFormat:@"%d",hour]];

and tells me to replace it with @"%02ld" or @"%ld"

             
time =  [time stringByAppendingString:[NSString stringWithFormat:@"%02ld",(long)minute]];

It was working fine when i was using Xcode 5.0.2.

so can we release app through Xcode 5.1 beta 5 to IOS 7.1 beta,7.1,6.1 to test on device & to App store?

Should i use Xcode 5.0.2 & use final(non beta) & wait for final version of Xcode 5.1.

P.S. I want to test my apps on device first time & will publish app on store first time..

2
For the warning, see Why does an NSInteger variable have to typecasted to type long? - Xcode 5.0.2 gives you the same warning if you compile for 64-bit. - Martin R

2 Answers

1
votes

You can't submit to the app store with a beta version of Xcode. You will have to build your release binary with Xcode 5.0.2.

That said, you should fix those warnings. Just because Xcode 5.0 didn't warn you about them doesn't mean they were ever right.

0
votes

There is a difference in this case when compiling for 64-bit vs. 32-bit.

In 64-bit NSInteger is a 64-bit value: typedef long NSInteger In 32-bit NSInteger is a 32-bit value: typedef int NSInteger

So when compiling for 32-bit the %02d is fine. When compiling for 64-bit the compiler wants a %02ld for the wider value. The way to fix this is to use %02ld and cast the value to a long as shown in your second code block. If using NSUInteger cast to unsigned long.

You can read more about this in these iOS articles from Apple:

String Format Specifiers

64-bit Transition Guide