Hi I get this warning when using %lu:
"format specifies type unsigned long but the argument has type unsigned int."
then when i replace to %u: the warning changes to:
"format specifies type unsigned int but the argument has type unsigned long."
here is my code:
NSString *viewName_ = [NSString stringWithFormat:@"myGreatView%lu", currentTagLoadedOnView-99];
where currentTagLoadedOnView:
NSUInteger currentTagLoadedOnView;
any help greatly appreciated....
Try any one of the below
1) Use both as unsigned int
NSString *viewName_ = [NSString stringWithFormat:@"myGreatView%u", currentTagLoadedOnView-99];
and declare currentTagLoadedOnView as NSUInteger currentTagLoadedOnView;
2) type cast to unsigned long
NSString *viewName_ = [NSString stringWithFormat:@"myGreatView%lu", (unsigned long) currentTagLoadedOnView-99];
and declare currentTagLoadedOnView as NSUInteger currentTagLoadedOnView;
3) Defined unsinged long as both
NSString *viewName_ = [NSString stringWithFormat:@"myGreatView%lu", (unsigned long) currentTagLoadedOnView-99];
and declare currentTagLoadedOnView as unsigned long currentTagLoadedOnView;
Note: Your warning will disappear if you use 64-bit architecture only(make changes to consistent data type) or 32-bit only(no change). If you use Standard architecture(including 64-bit)
, it will give this warning.