草庐IT

xcode - 快速 Xcode 单元测试 : Cannot convert value of type "Person" to expected argument type "Person"

我正在尝试编写一个单元测试类来测试我的自定义类。当我尝试使用自定义对象作为输入变量调用自定义类中的方法时,我得到:'无法将类型“Person”的值转换为预期的参数类型“Person”。“Person”是从NSManagedObject继承的类,输入对象是从中创建的。我对采用其他值类型的其他方法没有问题。该方法工作正常。测试类是唯一提示这个的。这是错误还是限制?有什么建议可以让我更深入地研究这个问题吗? 最佳答案 我之前遇到过这个问题。事实证明,被测系统(在我的例子中是调用对象的服务;对于您的示例,可能是PersonService)没

swift - Xcode 8.1 Swift 3 错误 : cannot convert value of type 'String' to expected argument type 'UnsafeMutableRawPointer'

包含varsceneData代码的行给出了一个错误,显然是因为“路径”字符串。有谁知道如何解决这个问题?谢谢!extensionSKNode{classfuncunarchiveFromFile(_file:String)->SKNode?{ifletpath=Bundle.main.path(forResource:file,ofType:"sks"){varsceneData=Data(bytesNoCopy:path,count:.DataReadingMappedIfSafe,deallocator:nil)!vararchiver=NSKeyedUnarchiver(forR

swift 3 : convert a null-terminated UnsafePointer<UInt8> to a string

我有一个capi,它返回一个空终止字符串,它是一个类型为unsignedchar*的数组。(对应于UnsafePointer)。Swift有初始化器String(validatingUTF8:),但参数必须是UnsafePointer(又名UnsafePointer),并且没有简单的方法可以在两者之间进行转换。如何将这个以null结尾的C字符串转换为Swift字符串? 最佳答案 在Swift3中,String有两个初始化器publicinit(cString:UnsafePointer)publicinit(cString:Unsa

ios - 以编程方式将自定义 UIViewcontroller 添加到 subview 但收到错误消息 "Cannot convert value of type..."

我正在尝试在Swift中以编程方式将自定义UIViewController类(UIPickerView)添加到我的主ViewController(不使用Storyboard)但我收到以下错误消息..."Cannotconvertvalueoftype'HabitViewViewController'toexpectedargumenttype'UIView'自定义UIPicker类:importUIKitclassHabitViewController:UIViewController,UIPickerViewDataSource,UIPickerViewDelegate{@IBOut

iphone - 为什么在将 Float 转换为 CGFloat 时 Xcode 给我一个警告 "Cannot convert value of type ' CGFloat' to expected argument type 'UnsafeMutablePointer"?

我正在尝试将Float值转换为CGFloat值,这里是我的代码:letmyFloatForR=0letr=CGFloat(myFloatForR)letmyFloatForG=0letg=CGFloat(myFloatForG)letmyFloatForB=0letb=CGFloat(myFloatForB)letmyFloatForA=0leta=CGFloat(myFloatForA)tintColor.getRed(r,green:&g,blue:&b,alpha:&a)但Xcode突然给我一个警告说:“无法将类型'CGFloat'的值转换为“tintColor”行上的预期参数类

ios - swift : How to convert String to string with time format?

我的字符串值包括时间,格式为"HH:mm"(16:50)我必须将此值转换为"hh:mm"格式(04:50)作为SWIFT中的字符串我试过NSDateFormatter之类的lettimeFormat=NSDateFormatter()timeFormat.dateFormat="hh:mm"vardateFromStr=timeFormat.dateFromString("16:50")varstrFromDate=timeFormat.stringFromDate(dateFromStr)但它不起作用..请告诉任何解决方案。 最佳答案

ios - 转换为 Swift 3 错误 : "Convert to Current Swift Syntax Failed Could not find test host for..."

当我尝试运行在升级到Xcode8之前完美运行的项目时,我不断收到错误“UseLegacySwiftLanguageVersion”(SWIFT_VERSION)isrequiredtobeconfiguredcorrectlyfortargetswhichuseSwift.Usethe[Edit>Convert>ToCurrentSwiftSyntax…]menutochooseaSwiftversionorusetheBuildSettingseditortoconfigurethebuildsettingdirectly.尝试转换为swift3.0后,我不断收到错误消息:Conve

java - Netbeans 中的 "Convert to try-with-resources"- Cool Beans?

我在Netbeans7.1.2中有以下代码:BufferedOutputStreambos=newBufferedOutputStream(newFileOutputStream(filename));bos.write(newRawData);bos.close();警告提示我“转换为try-with-resources”。当我选择这样做时,我的代码变为:try(BufferedOutputStreambufferedFos=newBufferedOutputStream(newFileOutputStream(filename))){bufferedFos.write(newRaw

java - Java 8 收集器问题类型不匹配 : cannot convert from List<Object> to List<String>

我使用早期版本的java8工作代码,我用它从列表中获取唯一值,但自从我升级到JDK66后,它给了我一个错误类型不匹配:无法从List转换至ListListinstList=newArrayList();while(res.next()){instList.add(res.getString("INST").toString());}ListinstListF=instList.stream().distinct().collect(Collectors.toList());res是我从数据库中获取的结果集,不知道哪里出了问题? 最佳答案

java - Firebase Firestore : How to convert document object to a POJO on Android

使用实时数据库,可以做到这一点:MyPojopojo=dataSnapshot.getValue(MyPojo.Class);作为一种映射对象的方法,如何使用Firestore来实现这一点?代码:FirebaseFirestoredb=FirebaseFirestore.getInstance();db.collection("app/users/"+uid).document("notifications").get().addOnCompleteListener(task->{if(task.isSuccessful()){DocumentSnapshotdocument=task