草庐IT

production_cast

全部标签

objective-c - XCode 单元测试中没有这样的模块 <product module name>

我有一个混合的objective-c和Swift项目,我尝试为它编写单元测试。我的项目名称是:Alphaproject我的产品模块名称是:Alphaproject我在我的主要目标(Alphaproject)中设置为YESDefinesModule并设置为YESEnableTestabilityforDebugonlyinthissameTarget.在我的测试类中,我尝试导入我的产品模块名称:@testable导入Alphaproject补充说明:我所有的项目文件都只是主要目标的一部分我的测试文件只是测试目标的一部分我的测试方案设置为构建调试配置。我还尝试清理Build文件夹(ALT+

swift - SecIdentity + Force Cast 违规 : Force casts should be avoided. (force_cast)

请不要标记重复的问题。大家好,我正在执行NSURLAuthenticationMethodClientCertificate,我在其中使用以下代码。如果我不使用swiftlint,哪个代码没问题。但是当我使用swiftlint时出现这个错误并且无法解决这个问题。尝试了很多请帮助我。在下面发布代码。varitems:CFArray?//letPKCS12Data=DataSourceManager.sharedInstance.serverPolicyManager?.PKCS12DatasecurityError=SecPKCS12Import(certData,options,&it

swift - 没有 'items' 候选产生预期的上下文结果类型 '(Observable<[Product]>) -> (_) -> _'

这是我的代码片段:classProductCategoryCell:UITableViewCell{@IBOutletweakvarcollectionViewProducts:UICollectionView!//otherstuff...funcsetProducts(){letproductsObservable=Observable.just([Product(name:"test",price:10.0),Product(name:"test",price:10.0),Product(name:"test",price:10.0)])productsObservable.bi

ios - 使用 Swift 的 Alamofire - "Could not cast value of type ' Swift._SwiftDeferredNSArray' (ox10a75ebb0) 到 'Photomania.PhotoInfo' (0x107ee7b90)。”

运行OSXElCap开发测试版、iOS9.0、Xcode7.0GM我正在关注RayWenderlich教程(http://www.raywenderlich.com/85080/beginning-alamofire-tutorial),但确实遇到了一些问题。在我创建请求路由器之前,我的应用程序无法运行。它构建正确,然后一旦开始加载,我就会在标题中看到调试器短语。构建错误描述为“Thread1:signalSIGABRT”。概述的行是:letimageURL=(photos.objectAtIndex(indexPath.row)as!PhotoInfo).url这是PhotoBrow

ios - 黄色警告 : Conditional cast from UITextDocumentProxy to UIKeyInput always succeeds

我正在使用键盘,我刚刚安装了xcode7beta2然后我收到很多警告。超过24个黄色错误我认为这会使键盘崩溃onxcode6.4无错误无键盘当然我发现很难解决这些错误。警告:ConditionalcastfromUITextDocumentProxytoUIKeyInputalwayssucceedsfunchandleBtnPress(sender:UIButton){ifletkbd=self.keyboard{iflettextDocumentProxy=kbd.textDocumentProxyas?UIKeyInput{textDocumentProxy.insertText

ios - Swift4 单元测试 : ViewController not found when type casting

我目前正在使用以下代码在MyViewController类上编写测试:letviewController=UIStoryboard(name:"Main",bundle:Bundle.main).instantiateViewController(withIdentifier:"MyViewController")XCTAssertNotNil(viewController.view)XCTAssertNotNil(viewControlleras?MyViewController)这个测试不起作用,第二个断言总是失败。当我调试时,我可以看到我的viewController具有正确的类

casting - 快速子类和类型转换

这是我做的测试:我定义了2个类:classTest1{varp1:String?="p1"init(){println("inittest1")}}classTest2:Test1{init(){super.init()p1="p2"println("inittest2")}}然后我创建一个Test2的实例letx=Test2()我会检查Test2是否是Test2的子类ifxisTest1{println("ok")}else{println("no")}但我有一个构建错误:Test1不是Test2的子类型我哪里错了?我试过了,没有成功,还有这个:iflety=xas?Test1{pr

ios - Swift:PrepareForSegue,Swift Cast 失败

我想在我的TableViewController中选择一个单元格。单元格的文本应该通过segue传输到FirstViewController的标签。我总是收到如下所示的错误。标识符正确。我的代码:overridefuncprepareForSegue(segue:UIStoryboardSegue!,sender:AnyObject!){if(segue.identifier=="BackToCalculator"){//letmyRow=tableView.indexPathForSelectedRow().row+1letvc=segue.destinationViewContro

swift - Xcode 6.3 和 Swift 1.2 中的新警告 : Cast from '[SKNode]' to unrelated type 'String' always fails

更新到xCode6.3/Swift1.2后,我遇到了一个我无法解决的错误:“从‘[SKNode]’转换为不相关的类型‘String’总是失败”。下面是我的GameScene代码,它从解析p-list开始。importSpriteKitclassGameScene:SKScene,SKPhysicsContactDelegate,NSXMLParserDelegate{varcurrentTMXFile:String?overridefuncdidMoveToView(view:SKView){/*Parsep-list*/letpath=NSBundle.mainBundle().pa

swift - 错误 : Could not cast value of type NSKVONotifying_MKUserLocation to Park_View. AttractionAnnotation

使用此功能时:funcmapView(mapView:MKMapView!,viewForAnnotationannotation:MKAnnotation!)->MKAnnotationView!{letannotationView=AttractionAnnotationView(annotation:annotation,reuseIdentifier:"Attraction")annotationView.canShowCallout=truereturnannotationView}发生此错误:Couldnotcastvalueoftype'NSKVONotifying_MK