views:

180

answers:

2

Does anyone know why there would be one-off errors with NSLog and NSString? It works fine in 99% of my program, but for some reason this error appears in one of my model's description method:

Example code:
localFileId = 7;
type = 2;
localId = 5;
NSLog(@"CachedFile localId=%d, 2=%d, localFileId=%d, type=%d, path=%@", localId, 2, localFileId, type, self.path);

Example Result: 
CachedFile localId=5, 2=0, localFileId=2, type=7, path=(null)

Notice the "0" that gets inserted in there, where it should be "2=2". This happens with NSString stringWithFormat as well.

+1  A: 
progrmr
No, each integer-type is subject to integer promotion when passed as an argument to a variadic function.
dreamlax
The problem is if the type of `localId` outranks `int`, which it would if it were a `long long int` or `long int`.
dreamlax
@dreamlax: you're right, thanks for the correction.
progrmr
Yeah, the long long ints were the problem. Thanks
David Liu