I’ve got a variable in my Core Data model set to the float type called “speech1Size”. I’m trying to use that variable to set the font size of a UILabel, but I’m getting errors each way I try it.
Running the following example returns this error:
“Method ‘+fontWithSize:’ not found (return type defaults to ‘id’)”
// first I get the value
NSNumber *fontSize = [detailViewController.detailItem valueForKey:@"speech1Size"];
// try to set the UILabel's font size
detailViewController.speech1Label.font = [UIFont fontWithSize:fontSize];
I’ve tried a variety of other things like casting as float, but that returns an error and this seems closest so far. I realize I’m missing something simple…Thank you for your time!!
The
fontWithSizemethod is an instance method, and you are trying to use it as a class method. Maybe you wanted to use+fontWithName:size:.Also, the size parameter is expected to be a CGFloat value. Try passing
[fontSize floatValue].