草庐IT

reference-parameters

全部标签

parameters - Swift:转换闭包参数?

以下代码导致编译器错误:Couldnotfindmember'Left'。letindexOfConstraint=constraints.indexOfObjectPassingTest{(constraint,idx,stop)inreturnconstraint.firstAttribute==.Left}在.Left之前添加NSLayoutAttribute可以修复错误,但是有没有办法将constraint转换为NSLayoutConstraint?例如,在Objective-C中,我可以在指定参数时强制转换constraint。NSUIntegerindexOfConstra

swift - Codable - arrayPropety [AnyObject] : Reference to member 'data' cannot be resolved without a contextual type

设置Codable类。AnyObjects数组产生编译错误:Referencetomember'data'cannotberesolvedwithoutacontextualtypeclassClassA:NSObject,Codable{//MARK:-Propertieslettitle:Stringletdata:[T]//dataisanarrayofeitherCodableobjectsofClassBorClassC.//MARK:-KeyesprivateenumCodingKeys:String,CodingKey{casetitlecasedata}required

parameters - 如何更改枚举中的参数值(Swift)

和你们一样,我是Swift的新手。我不知道如何在创建后更改枚举中的参数。所以。有SimpleProtocol和SimpleEnum,它们都符合这个协议(protocol)。//SimpleProtogoeshereprotocolExampleProtocol{varsimpleDescription:String{get}mutatingfuncadjust()}//AndSimpleEnumgoeshereenumSimpleEnum:ExampleProtocol{casefirst(Int)casesecond(Int)casethird(Int)varsimpleDescri

ios - "Ambiguous reference to member map"来自具体类型

这是我的代码。它使用来自CoreBluetooth的CBUUID。让我们假设v的转换是有效的。importUIKitimportCoreBluetoothfuncconvert(v:AnyObject)->[String:String]{return(vas![CBUUID:NSData]).map{(uuid,data)in(uuid.UUIDString,NSString(data:data,encoding:NSUTF8StringEncoding)??"")}}想法是通过为CBUUID调用CBUUID.UUIDString并通过调用适当的NSString构造函数来获取字典的字符

ios - Swift + Storyboard : How to keep strong reference to show segue controller?

我有两个Controller:HistoryViewController,它有一个“浏览”按钮。这嵌入在NavigationController中WebBrowserViewController,将通过HistoryViewController中的浏览按钮访问浏览按钮连接正常。当我点击它时,它会将我带到网络浏览器ViewStoryboard。但是,当我按下返回键并再次点击“浏览”按钮时,它总是会生成一个新的Web浏览器View。因此,如果我在Web浏览器View中的某个页面上返回历史View,然后再次点击“浏览”,我总是会返回主页并丢失当前页面。有没有一种方法可以保持对WebBrows

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*

ios - 错误 : generic parameter 'T' could not be inferred in swift

我有一个函数,可以从嵌套数组中生成扁平数组。它非常适合int数组。letarray:[Any]=[1,2,[3]]funcmakeFlatArray(_array:[Any])->[Int]{varflatArray=[Int]()foriteminarray{ifletitem=itemas?Int{flatArray.append(item)}elseifletitem=itemas?[Any]{letresult=makeFlatArray(item)flatArray+=result}}returnflatArray}但我想让它成为通用的,但我在尝试时遇到了错误。funcmak

swift 错误 : Generic parameter 'T' is not used in function signature

我正在尝试使用泛型来简化一些XML反序列化,但是,Swift2.0令人窒息地说我没有在我的方法签名中使用泛型。我很困惑为什么它会抛出这个错误,因为我直接实例化了传入的类类型。关于这个错误的原因有什么建议吗?确切的错误是:Genericparameter'T'isnotusedinfunctionsignatureMTXMLDeserializable是我正在使用的基类,它的方法是:init(properties:Dictionary?,propertyMap:Dictionary?)这是有问题的方法:functransformResponse(responseData:XMLIndex

ios - 错误 : UICollectionView must be initialized with a non-nil layout parameter

我正在尝试从youtube教程创建一个类似FacebookMessenger的应用程序。我有一个主页,用户可以在其中单击BarButton打开聊天。主页工作正常,直到我单击BarButton打开聊天,它崩溃并显示以下错误消息“必须使用非零布局参数初始化UICollectionView”。我是iOS开发的新手,所以无法真正理解问题出在哪里,因为我已经有了init方法。由于我有不同的观点,我是否在AppDelegate中遗漏了什么,这令人困惑:(。非常感谢您的帮助。谢谢!classChatViewController:UICollectionViewController,UICollect

xcode - iOS8.0 的 CompileSwift 状态为 "the current deployment target does not support automated __weak references"

我正努力在Swift应用程序中使用静态库(从ObjectiveC编译)。我有一个包含相关header的ObjectiveC桥接header。构建应用程序时出现此错误../someDirectory/Xcode/FirstSteps/headers/Acme.h:89:thecurrentdeploymenttargetdoesnotsupportautomated__weakreferencesAcme类确实使用弱引用,但部署目标是iOS8.0,它应该支持它们。我是不是找错树了?Acme.h的第89行显示:-(void)addTopicListener:(__weakNSObject*