Format specifies type "unsigned long" but the argument has type "int"
I get this error in XCode and no matter what format specifier I put in or if I change to NSInteger, NSUInteger, long or int, still get errors!? How can I fix this?
In
-(UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view
{
I have these lines, in line 2 is the error at @"%lu",(row % max)
NSUInteger max = (NSInteger)[self.calendar maximumRangeOfUnit:NSCalendarUnitHour].length;
[lblDate setText:[NSString stringWithFormat:@"%lu",(row % max)]];
lblDate.textAlignment = NSTextAlignmentRight;
Thanks for help !
For NSInteger
you should use %td
or %tu
for NSUInteger
See this link for more details https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/Strings/Articles/formatSpecifiers.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With