lightmaster2006
lightmaster2006

Reputation: 89

Argument labels '(_:)' do not match any available overloads

Getting stuck after updating here.

Get "Argument labels '(_:)' do not match any available overloads"

On this code:

@IBAction func calculateButton(sender: UIBarButtonItem) {


        let w = Float(panelWidthTextField!.text!)
        let sw = Float(panelsWideTextField!.text!)
        let pi = Float(panelPitchTextField!.text!)
        let sizew = sizeWidthModel(pw:w!,psw:(sw)!,ptc:pi!)

        let formatter = NumberFormatter()
        **// Error is on the line under.**
        let swt = formatter.stringFromNumber(NSNumber(sizew.width()))!

SizeWidthModel:

import Foundation

class sizeWidthModel {
var pw:Float
var psw:Float
var ptc:Float

init (pw:Float,psw:Float,ptc:Float){
    self.pw=pw
    self.psw=psw
    self.ptc=ptc
}

func width()->Float {
    return pw*psw/ptc
}

func wswidth()->Float {
    return pw*psw
}
}

All help is appreciated

Upvotes: 0

Views: 2006

Answers (2)

sword
sword

Reputation: 26

I guess you are using the swift3.0

Swift3.0 need to clear the parameter name in the absence of '_' write modification parameters

so use:

let swt = formatter.string(from: NSNumber(value:sizew.width()))!

Upvotes: 1

bsarrazin
bsarrazin

Reputation: 4040

Ok, first off classes must always start with an upper case letter, that's how you recognize they are Types.

This line let swt = formatter.stringFromNumber(NSNumber(sizew.width()))! is taking a Float converting it to an NSNumber, then going through a formatter, to end up as a String

Why not just use string interpolation?

let swt = "\(sizew.width())"

Upvotes: 1

Related Questions