I've got a function which updates the rgb
variables. When its called within the class it works fine but if I try to access it through another class wont do anything.
var red : CGFloat! = 0.5;
var green : CGFloat! = 0.5;
var blue : CGFloat! = 0,5;
func updateColour(r:CGFloat, g:CGFloat, b:CGFloat){
red = r;
green = g;
blue = b;
}
I'm trying to set the values from another class using the code below. I used a print command to make sure the function is being called but the variables won't update.
let canvas = canvasViewController() as canvasViewController;
canvas.updateColour(r: red, g: green, b: blue)
Not sure if I'm setting the variables incorrectly or accessing the class wrong but any help will be greatly appreciated.
Actually, I think you did something wrong, you need to revisit your code, or share more code with us.
BTW, I tried your code in Swift 3.0 in Playground and everything works fine, try it yourself: