• by TillE on 1/30/2016, 4:22:26 PM

    I hope they do adopt that suggested change to method calls. Swift is a nice language, but there's still some awkwardness due to its required compatibility with Objective C. I think if you don't come from that background, then having all named arguments except the first one seems really arbitrary and nonsensical.

  • by fleshweasel on 1/30/2016, 7:50:31 PM

    The title they chose implies that they're actually changing the APIs to take full advantage of Swift language features. Perhaps they should have named the article "We're renaming some classes and methods."

  • by bjourne on 1/30/2016, 6:50:17 PM

    If it is one that that should be known about Apple software by now, is that things will change from under your feet. :)

  • by Benjammer on 1/30/2016, 11:43:55 PM

    Could they just go all the way and use a mandatory first argument name to make things even more concise? That would get away from something that annoys a lot of people about Swift, the implicitly unnamed first arguments.

    Something like this:

        class BezierPath: NSObject {
          func add(LineTo lineTo: CGPoint) {}
          func add(ArcWithCenter center: CGPoint, radius: CGFloat, 
                              startAngle: CGFloat, endAngle: CGFloat, 
                              clockwise: Bool) {}
          func add(CurveTo endPoint: CGPoint, controlPoint1 point1: CGPoint, 
                              controlPoint2 point2: CGPoint) {}
          func add(QuadCurveTo endPoint: CGPoint, controlPoint: CGPoint) {}
        }
    
        class main {
            func run() {
                let path = BezierPath()
                let point1 = CGPoint()
                let point2 = CGPoint()
    
                path.add(LineTo: CGPoint(x: 100, y: 0))
                path.add(ArcWithCenter: CGPointZero, radius: 20.0, 
                                 startAngle: 0.0, endAngle: CGFloat(M_PI) * 2.0, 
                                 clockwise: true)
                path.add(CurveTo: CGPoint(x: 100, y: 0), controlPoint1: point1, 
                                 controlPoint2: point2)
                path.add(QuadCurveTo: point2, controlPoint: point1)
            }
        }
    
    The difference is mostly that it looks even more concise when using code completion. You would see:

        path.add(LineTo: CGPoint)
    
    Instead of:

        path.addLineTo(point: CGPoint)

  • by protomyth on 1/30/2016, 5:33:27 PM

    I do wish the Swift developers had allowed actual Objective-C calls in Swift to make it look the same.

    Objective-C

      [aPath addLineToPoint:CGPointMake(200.0, 40.0)];
    
    proposed

      aPath.(addLineToPoint:CGPoint(200.0, 40.0));
    
    the more complicated example would be:

    Objective-C

      [object selector1:item1 selector2:item2];
    
    to

      object.(selector1:item1, selector2:item2);
    
    although I'm still not sure about the love of commas