You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Swift Xcode-beta环境运行代码报Extra Argument in call错误,无其他报错

报错原因

你出现Extra Argument in call报错的核心原因是Swift 字符串插值的格式化语法使用错误,你当前写的\((format: "%.2f"), 变量名)的语法不符合Swift规范,相当于你给插值传入了两个参数(一个format字符串、一个变量),系统识别为多余参数。

修复方案

有两种常用修复方式:

方式1:使用String(format:)整体格式化(推荐,代码更简洁)

你可以把所有变量放到String(format:)的参数列表里,对应前面的格式占位符即可,示例写法:

self.blendShapeLabel.text = String(format: "The blendshapes are %.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f", 
eyeBlinkR, eyeBlinkL, eyeLookInL, eyeLookInR, eyeLookOutL, eyeLookOutR, eyeLookDownL, eyeLookDownR, eyeLookUpL, eyeLookUpR, eyeSquintL, eyeWideL, eyeSquintR, eyeWideR, mouthL, mouthR, mouthFrownL, mouthFrownR, mouthSmileL, mouthSmileR, mouthDimpleL, mouthDimpleR, mouthStretchL, mouthStretchR, mouthCloseCoeff, mouthPucker, mouthFunnel, mouthRollLower, mouthRollUpper, mouthPressL, mouthPressR, mouthLowerDownL, mouthLowerDownR, mouthUpperUpL, mouthUpperUpR, jawForward, jawLeft, jawRight, jawOpen, cheekPuff, cheekSquintL, cheekSquintR, noseSneerL, noseSneerR, tongueOut, browInnerUp, browDownL, browDownR, browOutterL, browOutterR)

方式2:修改单插值的格式化写法

如果你要在每个插值里单独格式化,正确语法是String(format: "%.2f", 变量名),把原来的\((format: "%.2f"), eyeBlinkR)改成\(String(format: "%.2f", eyeBlinkR))即可,所有插值位置都按这个规则修改就行。

内容的提问来源于stack exchange,提问作者Jay Tikoo

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.07 13:24:01