Reputation: 89
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
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
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