I am getting the compiler error "Class methods may only be declared on a type". I am not sure why I am getting this to be honest. All the stack overflow answers apply to another senario. Any suggestions are appreciated.
class func fontWithSize(var size : CGFloat) -> UIFont
{
let font : UIFont = UIFont (name: "Roboto-Regular", size: size)!
return font;
}
One thing that looks odd is the var
keyword in front of the parameter name.
The other thing; are you declaring this method inside a class
definition?
You're probably getting this error because you're declaring the method at the top-level or global scope. If that's your intention the you don't need the class
keyword anyway.
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