草庐IT

Type_Ary

全部标签

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

ios - 切换 map : error: cannot invoke 'map' with an argument list of type '((_) -> _)'

我不明白为什么这个有效:vararr=[4,5,6,7]arr.map(){xinreturnx+2}虽然这个不是arr.map(){xinvary=x+2returny}有错误Playgroundexecutionfailed:MyPlayground.playground:13:5:error:cannotinvoke'map'withanargumentlistoftype'((_)->_)'arr.map(){ 最佳答案 这里的问题是有错误信息。通常,当您看到类似cannotinvoke..with...的内容时,这意味着编

swift - 开启 Any.Type

我正在尝试快速打开一个类型。我不是要打开对象实例的类型,而是要打开实际类型本身。例如:lett:Any.Type=Int.selfswitcht{caseisInt:print("int")default:print("other")}我希望这会打印“int”,但它属于默认情况。我可以用if语句完成预期的结果,例如,ift==Int.self{print("tisanint")}但我希望有一种方法可以通过开关来做到这一点。我已经阅读了Apple的“TypeCasting”文档,可能不够彻底,因为我看不到在这里应用它的方法。 最佳答案

ios - ResponseSerializer 'cannot call value of non-function type ' NSHTTPURLResponse ?'' 与 Swift 3

在更新到Xcode8beta6之前,我一直在毫无问题地使用以下代码。它类似于thisexample来自Alamofire存储库。今天早上我将我的Alamofire库更新到最新的swift3分支,现在与beta6兼容。它显示错误:Cannotcallvalueofnon-functiontype'HTTPURLResponse?'存在类似问题here,但它不是基于当前版本的Swift和Alamofire。据我了解,这个错误是因为它认为我正在尝试返回Request属性(property)response而不是函数response(responseSerializer:,completion

ios - 使用 Swift 时出现错误 "nil requires a contextual type"

我想在代码中实现以下目标:classMyService{letmySubject=BehaviorSubject(value:nil)//....}不幸的是,我收到“nil需要上下文类型”错误。在我真正把东西放在那里之前,我希望这个主题是“空的”。那么我怎样才能将nil作为参数传递呢?我可以将它转换为我自己的类型以使其工作吗? 最佳答案 基于referenceforRxSwiftBehaviorSubject,init(value:)初始化器声明为publicinit(value:Element)其中value参数描述为:value