Cannot invoke value of type

Tony

I was trying to append my Point array with some data, although I got an error of type, shown below. Appreciate any help, thanks!

for i in slew {
    var x = i[0]
    var y = i[1]
        pointsArray.append(Points.GetPoint(origin:Points.Point(x:x,y:y))) //Cannot invoke value of type 'Points.GetPoint.Type' with argument list '(origin: Points.Point)'

}


class Points: NSObject {
    struct Point {
        var x = Double(0.0)
        var y = Double(0.0)
    }

    struct GetPoint {
        var origin = Point()

        var point: Point {
            get {
                let x = origin.x
                let y = origin.y
                return Point(x:x, y:y)
            }
        }
    }
}
Alistra

This is how the code should look like, not sure if you wanted to do a factory with the GetPoints, but this is not a swift pattern.

for i in slew {
    var x = i[0]
    var y = i[1]
    pointsArray.append(Points.Point(x:x,y:y)) 
}

class Points: NSObject {
    struct Point {
        var x = Double(0.0)
        var y = Double(0.0)
    }
}

To make it even more swifty you can use CGPoint instead of your own point and make the for into a map.

pointsArray = slew.map { CGPoint(x: $0[0], y: $0[1]) }

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Cannot invoke "+=" with an argument list of type (Int, @value Int)

From Dev

Cannot invoke add on the array type

From Dev

Cannot invoke initializer for type 'UnsafeMutablePointer'

From Dev

Cannot invoke $function with object of type *

From Dev

Cannot invoke initializer for type: with an argument list of type:

From Dev

Cannot invoke animateWithDuration with an argument list of type

From Dev

SignalR Cannot invoke a non-delegate type

From Dev

IntegerType: Cannot invoke 'init' with an argument of type 'T'

From Dev

Cannot invoke 'init' with argument of type 'NSNumber' (Swift)

From Dev

Cannot invoke 'sizeof' with an argument list of type '([Double])'

From Dev

Cannot invoke compareTo(double) on the primitive type double

From Dev

Cannot invoke filter with an argument list of type ((_) -> _)

From Dev

Cannot invoke 'startAccelerometerUpdatesToQueue' with an argument list of type

From Dev

Cannot invoke substringToIndex with an arguement list type int

From Dev

Cannot invoke 'filter' with an argument list of type '((_) -> _)'

From Dev

Cannot invoke '-' with an argument list of type (CGFloat, CGFloat)

From Dev

Cannot invoke 'dataTask' with an argument list of type

From Dev

Cannot invoke 'init' with argument list of type StringLiteralConvertible

From Dev

cannot invoke getjsonobject(int) on the primitive type int

From Dev

Cannot invoke my method on the array type int[]

From Dev

Cannot invoke <method> with and argument list of type '(String)'

From Dev

Cannot invoke nextint() on the primitive type int

From Dev

Cannot invoke 'append' with an argument list of type'(String)'

From Dev

cannot invoke 'dequeReusable...' with an argument of type '(String)'

From Dev

Cannot invoke 'insert' with an argument list of type

From Dev

Cannot invoke 'enumerate' with an argument list of type '(String)'

From Dev

Cannot invoke 'indexOf' with an argument list of type '(ChecklistItem)'

From Dev

Cannot invoke function with an argument list of type '()'

From Dev

Cannot invoke initializer for type with no arguments - Swift

Related Related

  1. 1

    Cannot invoke "+=" with an argument list of type (Int, @value Int)

  2. 2

    Cannot invoke add on the array type

  3. 3

    Cannot invoke initializer for type 'UnsafeMutablePointer'

  4. 4

    Cannot invoke $function with object of type *

  5. 5

    Cannot invoke initializer for type: with an argument list of type:

  6. 6

    Cannot invoke animateWithDuration with an argument list of type

  7. 7

    SignalR Cannot invoke a non-delegate type

  8. 8

    IntegerType: Cannot invoke 'init' with an argument of type 'T'

  9. 9

    Cannot invoke 'init' with argument of type 'NSNumber' (Swift)

  10. 10

    Cannot invoke 'sizeof' with an argument list of type '([Double])'

  11. 11

    Cannot invoke compareTo(double) on the primitive type double

  12. 12

    Cannot invoke filter with an argument list of type ((_) -> _)

  13. 13

    Cannot invoke 'startAccelerometerUpdatesToQueue' with an argument list of type

  14. 14

    Cannot invoke substringToIndex with an arguement list type int

  15. 15

    Cannot invoke 'filter' with an argument list of type '((_) -> _)'

  16. 16

    Cannot invoke '-' with an argument list of type (CGFloat, CGFloat)

  17. 17

    Cannot invoke 'dataTask' with an argument list of type

  18. 18

    Cannot invoke 'init' with argument list of type StringLiteralConvertible

  19. 19

    cannot invoke getjsonobject(int) on the primitive type int

  20. 20

    Cannot invoke my method on the array type int[]

  21. 21

    Cannot invoke <method> with and argument list of type '(String)'

  22. 22

    Cannot invoke nextint() on the primitive type int

  23. 23

    Cannot invoke 'append' with an argument list of type'(String)'

  24. 24

    cannot invoke 'dequeReusable...' with an argument of type '(String)'

  25. 25

    Cannot invoke 'insert' with an argument list of type

  26. 26

    Cannot invoke 'enumerate' with an argument list of type '(String)'

  27. 27

    Cannot invoke 'indexOf' with an argument list of type '(ChecklistItem)'

  28. 28

    Cannot invoke function with an argument list of type '()'

  29. 29

    Cannot invoke initializer for type with no arguments - Swift

HotTag

Archive