Dismiss
Announcing Stack Overflow Documentation

We started with Q&A. Technical documentation is next, and we need your help.

Whether you're a beginner or an experienced developer, you can contribute.

Sign up and start helping → Learn more about Documentation →

I'm getting the following error on my circleLayer.strokeEnd line: "Instance member 'sales' cannot be used on type 'ViewController'." Does anyone know why I can't divide an Int by another Int and use it here? (Before this, I had 1.0 in place of "(sales/salesGoal)" and it worked great). This is a very simplified version of the code I'm using.

var sales = 0
var salesGoal = 2

  class salesCircleView: UIView {

    override init(frame: CGRect) {

       circleLayer.strokeEnd = (sales/salesGoal)

    }
  }

Any help figuring out the correct syntax would be helpful. Thanks!

share|improve this question
    
Your error is not due to the division. Is this inside of a class called ViewController? that is probably where your problems lie. – PEEJWEEJ Jun 21 at 0:02
    
You should consider posting the code for you View Controller, specifically those parts that show the context for your declaration of sales and salesGoal as well as where in the View Controller you try to access them. Also, note that if these variables are declared in the class View Controller they cannot be accessed in a different class (well not without a little work). – Ike10 Jun 21 at 0:17

So I did find that all of my code (including my variables) was inside a class called "View Controller" at the top. I moved the sales and salesGoal variables outside that class, now under the 'Import UIKit" and it worked like a charm.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.