Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Format specifies type "unsigned long" but the argument has type "int"

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 !

like image 239
Kreuzberg Avatar asked Dec 09 '22 04:12

Kreuzberg


1 Answers

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

like image 161
Sash Zats Avatar answered Apr 28 '23 03:04

Sash Zats