草庐IT

Duck-typing

全部标签

swift - 无法为类型 'sqlite3_destructor_type' 调用初始值设定项

到目前为止answerfromMartinR已经完美地工作了。但是从Swift2开始,它现在会引发错误Cannotinvokeinitializerfortype'sqlite3_destructor_type'withanargumentlistoftype'(COpaquePointer)'在那些行中:privateletSQLITE_STATIC=sqlite3_destructor_type(COpaquePointer(bitPattern:0))//https://stackoverflow.com/a/26884081/1271826privateletSQLITE_TR

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

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

swift - Swift 闭包中的 "type of expression is ambiguous without more context"错误

我的Swift代码中出现了一个奇怪的类型相关错误:typeofexpressionisambiguouswithoutmorecontext.即使我提供了完整的类型信息,也会发生这种情况。这是重现它的代码。我有两个结构:structPerson{letname_:Stringletaddress_:Address}structAddress{letstreet_:Stringletcity_:String}然后我创建一个包含2个函数的结构来获取和设置Person的address:structLens{letextract:(A)->Bletcreate:(B,A)->A}当我尝试创建一

ios - 我如何调试 : libc++abi. dylib : terminating with uncaught exception of type NSException?

很抱歉问这个菜鸟问题,我知道这个问题之前已经被问过数千次了,我知道是因为我之前遇到过这个问题数千次。但这次谷歌没有帮助。错误/终端打印:libc++abi.dylib:terminatingwithuncaughtexceptionoftypeNSException我通常知道是什么类型的情况导致了这种情况,因为我过去遇到过这个问题并且修复起来非常简单,通常是函数命名错误或某些UI元素与我的代码之间的链接断开,但现在我有不知道是什么原因造成的。我已经尝试过的:我在起始ViewController上添加了大量断点,它通过了所有@IBOutlets而没有抛出任何问题。我在AppDelegat

swift 3.0.2 给出错误 '' Type 'bool' is broken"

我正在使用这个结构并使用这个structRide{varisRideForNow:Bool!}varsheduleRide:Ride?sheduleRide=Ride()sheduleRide?.isRideForNow=false当我这样使用时它工作正常if(sheduleRide?.isRideForNow)!{//somecode}但我不知道为什么下面的代码会给出错误“Type'bool'isbroken”,即使这里没有可选链接if(sheduleRide!.isRideForNow){//somecode} 最佳答案 这是一

ios - 无法将值类型 'TableViewController.Type' 转换为预期的参数类型 'UIViewController'

我正在制作一个需要注册和登录的应用。我为此使用了Parse。如果登录/注册成功,我想将ViewController移动到TableViewController。但是我收到此错误:“无法将值类型‘TableViewController.Type’转换为预期的参数类型‘UIViewController’。这是我收到错误的行:funclogInViewController(logInController:PFLogInViewController,didLogInUseruser:PFUser){self.dismissViewControllerAnimated(true,completi

ios - swift 错误 : '&' used with non-inout argument of type 'UnsafeMutablePointer'

我正在尝试从中转换以下Objective-C代码(source)-(CGRect)dimensionsForAttributedString:(NSAttributedString*)asp{CGFloatascent=0,descent=0,width=0;CTLineRefline=CTLineCreateWithAttributedString((CFAttributedStringRef)asp);width=CTLineGetTypographicBounds(line,&ascent,&descent,NULL);//...}进入swift:funcdimensionsFo

arrays - 苹果 swift : Initialize Array of Generic Type

我有一个泛型类型T的数组(类的成员)。泛型类型只能是数字类型(double、int等)。我的问题是如何在初始化程序中将此数组初始化为所有相同的数字?我看过这个:self.data=Double[](count:3,repeatedValue:1.0)所以我尝试了这个但是它不起作用......self.data=T[](count:3,repeatedValue:1.0)有人知道怎么做吗?谢谢。 最佳答案 所以,这是我刚刚做的:protocolInitable{init()}classBar:{varar:T[]init(length

ios - swift 'use of undeclared type'

我目前正在尝试用swift编写一个小的iOS应用程序,其中我有这些类:masterTableViewControlleraddViewController和deleteViewController,它们中的每一个都连接到一个viewController,顾名思义。masterTableViewController应该使用预定义函数发送一些数据:overridefuncprepareForSegue(segue:UIStoryboardSegue,sender:AnyObject!){if(segue.identifier=="showDetails"){varselectedIndex

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