Require Integer Value not Memory Address whilst avoiding Invalid receiver type compiler warning
- by Dave Anderson
I have the following code;
int days = [[SettingsUtils daysToRetainHistory] intValue];
[retainHistory setText:[NSString stringWithFormat:@"Days to retain History: %d", days]];
[daysToRetainHistory setValue:days animated:NO];
where [SettingsUtils daysToRetainHistory] is as follows;
+ (int) daysToRetainHistory {
return (int)[[NSUserDefaults standardUserDefaults] objectForKey:@"CaseBaseDaysToRetainHistory"];
}
I get the compiler warning Invalid receiver type 'int' because I call intValue on an int but unless I do this I can't seem to get the integer value out and always end up with the memory address i.e. 98765432 instead of 9 which ruins the UILabel display [retainHistory] and the UISlider [daysToRetainHistory] value.
How do I avoid the compiler warning and still get my integer value in the label and the necessary float value for setting the UISlider value?