草庐IT

ARGUMENT

全部标签

swift - 核心数据 [NSSet intersectsSet :]: set argument is not an NSSet

我有两个关系表。在尝试保存产品的ShopItem类中:letproductEntity=NSEntityDescription.entityForName("Product",inManagedObjectContext:self.managedObjectContext!)product=Product(entity:productEntity!,insertIntoManagedObjectContext:self.managedObjectContext!)ifletproduct_title:String=jsonObj["product_title"]as?String{pr

swift 泛型 : Constraining Argument Types

来自C++背景(模板),我很难理解为什么以下Swift代码(泛型)无法编译:funcbackwards(array:[T])->[T]{letreversedCollection=array.sort(>)returnreversedCollection}我的理解是T是一个通用类型,我不对其施加任何约束()并声明array类型为Array.然而这会产生以下错误:Ambiguousreferencetomember'sort()'我知道可以使用协议(protocol)对泛型类型施加约束。但是,在这种情况下,我不希望对T有任何限制。.相反,我想限制第一个参数的类型。我已经阅读了Apple关

swift - 整数类型 : Cannot invoke 'init' with an argument of type 'T'

我有一个返回范围内整数的函数:funcrandomNumber(min:T,max:T)->T{letn=max-min+1letu=UInt32(n)//Error:Cannotinvoke'init'withanargumentoftype'T'letr=arc4random_uniform(u)returnr+min}我不明白为什么这不起作用,因为UInt32最上面的协议(protocol)是UnsignedIntegerType,它符合IntegerType。我必须将n变成UInt32因为arc4random_uniform()需要一个UInt32作为参数为什么这行不通?

xcode - swift 错误 : Cannot find an initializer for type 'Double' that accepts an argument list of type '(String)'

我正在尝试从标记为“temperatureTextField”的文本字段中获取数据并将其分配给“t”,这是一个Double。理想情况下,用户应该向temperatureTextField添加一个数字值。这是我的方法:@IBOutletweakvartemperatureTextField:UITextField!@IBActionfuncconvert(sender:AnyObject){lett=Double(temperatureTextField.text!)lettempM=TemperatureModel(temp:t!)temperatureTextField.text=S

Swift 2.0 : Cannot invoke with an argument list of type. ..(HTTP 请求)

自从我升级到Xcode7beta后,我遇到了一个无法修复的错误。这是我的DataManager.swift中的完整代码importFoundationvarTopAppURL:String=String()varnumberAsked:String=String()classDataManager{classfuncgetInfo(ID:String){TopAppURL="http://sweetapi.com/?=\(ID)"numberAsked=ID}classfuncloadDataFromURL(url:NSURL,completion:(data:NSData?,erro

ios - 在 Swift 数组上使用过滤器会给出 "cannot invoke filter with an argument list of type (Object) throws -> Bool,"但参数不会抛出

我无法确切地弄清楚Swift在这里期望什么样的参数列表,因为当我在swift数组上调用“filter”时出现错误。这是我的代码:funcsetDefaultBook(){varbook:BookletfetchRequest:NSFetchRequest=Book.fetchRequest()ifletfetchResults=try?managedObjectContext.fetch(fetchRequest){book=fetchResults.filter{$0.title==defaultBookTitle}}...}一本书是一个NSManagedObject,一本书的标题是

ios - UILabel 上的 Swift map "Anonymous closure argument not contained in closure"

为UITableViewCell的实例在contentView上对addSubview()进行三个单独的调用可能会简化为Swiftmap(_:):[nameLabel,numberLabel,informationLabel].map(contentView.addSubview($0))然而,简写会抛出一个错误:“闭包中不包含匿名闭包参数”。.forEach会是这里最好的吗? 最佳答案 此代码无效,因为它使用了一个匿名闭包参数$0,但没有在闭包中。[nameLabel,numberLabel,informationLabel].m

objective-c - Swift 中的 block 显示错误 "Missing argument for parameter #2 in call"

关闭。这个问题是notreproducibleorwascausedbytypos.它目前不接受答案。这个问题是由于错别字或无法再重现的问题引起的。虽然类似的问题可能是on-topic在这里,这个问题的解决方式不太可能帮助future的读者。关闭7年前。Improvethisquestion我现在正在使用JonasGessner的JGActionSheet在我的项目中使用Swift,示例是由Objective-C编写的,当我尝试将block转换为Swift时,Xcode显示错误“调用中参数#2缺少参数”,这是我编写的代码和屏幕截图:Objective-C示例JGActionSheet*

swift - 为什么我们可以在闭包的类型注释中使用 "internal argument labels",而它们(看起来)永远无法访问?

背景这自然是合法的:letclosure:(Int,Int)->()={print($0+$1)}closure(1,2)//3鉴于,自进化提案实现以来SE-0111:Removetypesystemsignificanceoffunctionargumentlabels在Swift3中,以下内容是不合法的:letclosure:(a:Int,b:Int)->()={/*...*/}Error:functiontypesmaynothaveargumentlabela,use_instead.这是预期的,正如SE-0111中的引述:Functiontypesmayonlybedefin

Vue脚手架报错:‘v-model‘ directives require no argument 解决方案

1、报错:'v-model'directivesrequirenoargument 截图 2、原因:ESLint对vetur进行了eslint检查 3、解决方法①修改模板中使用v-show将v-model:show="show"改为v-model="show"②vetur插件的作者给出了解决办法 我们可以把eslint对该插件的检查关闭在VScode中,打开“文件>首选项>设置”,搜索 Vetur›Validation: Template,关闭语法检查 保存,再看项目,正常运行!!!问题解决