草庐IT

Type_Ary

全部标签

ios - 错误 : Initializers may only be declared within a type

这是我的代码extensionUIImage{convenienceinit(color:UIColor,size:CGSize=CGSizeMake(1,1)){letrect=CGRectMake(0,0,size.width,size.height)UIGraphicsBeginImageContext(rect.size)letcontext=UIGraphicsGetCurrentContext()CGContextSetFillColorWithColor(context,color.CGColor)CGContextFillRect(context,rect)letima

ios - 错误 : Initializers may only be declared within a type

这是我的代码extensionUIImage{convenienceinit(color:UIColor,size:CGSize=CGSizeMake(1,1)){letrect=CGRectMake(0,0,size.width,size.height)UIGraphicsBeginImageContext(rect.size)letcontext=UIGraphicsGetCurrentContext()CGContextSetFillColorWithColor(context,color.CGColor)CGContextFillRect(context,rect)letima

swift 4 : Cannot convert value of type '(_) -> ()' to expected argument type '() -> ()' or Argument passed to call that takes no arguments

使用XCode9,Beta3。Swift4。statsView.createButton("Buttonname"){[weakself]Voidin//stuffstuffself?.doSomething()}我遇到了数百个这样的错误,我该如何修复它们?错误:Cannotconvertvalueoftype'(_)->()'toexpectedargumenttype'()->()'Argumentpassedtocallthattakesnoarguments 最佳答案 我们似乎不再在Swift4中使用Voidin了。我是如何

swift 4 : Cannot convert value of type '(_) -> ()' to expected argument type '() -> ()' or Argument passed to call that takes no arguments

使用XCode9,Beta3。Swift4。statsView.createButton("Buttonname"){[weakself]Voidin//stuffstuffself?.doSomething()}我遇到了数百个这样的错误,我该如何修复它们?错误:Cannotconvertvalueoftype'(_)->()'toexpectedargumenttype'()->()'Argumentpassedtocallthattakesnoarguments 最佳答案 我们似乎不再在Swift4中使用Voidin了。我是如何

ios - executeFetchRequest 抛出 fatal error : NSArray element failed to match the Swift Array Element type

我正在使用CoreData测试swift并创建了以下代码:importUIKitimportCoreDataclassContact:NSManagedObject{@NSManagedvarname:String@NSManagedvaremail:Stringclassfuncexecute(){letappDel:AppDelegate=(UIApplication.sharedApplication().delegateasAppDelegate)letcontext:NSManagedObjectContext=appDel.managedObjectContext!lete

ios - executeFetchRequest 抛出 fatal error : NSArray element failed to match the Swift Array Element type

我正在使用CoreData测试swift并创建了以下代码:importUIKitimportCoreDataclassContact:NSManagedObject{@NSManagedvarname:String@NSManagedvaremail:Stringclassfuncexecute(){letappDel:AppDelegate=(UIApplication.sharedApplication().delegateasAppDelegate)letcontext:NSManagedObjectContext=appDel.managedObjectContext!lete

ios - Swift 3.0 迁移错误 : Type 'Element' constrained to non-protocol type 'IndexPath'

我正在尝试使用xCode将我的代码库迁移到swift3.0。有几个问题我无法理解。问题:类型“Element”被限制为非协议(protocol)类型“IndexPath”在错误导航面板的左侧,它仅显示错误下方。我无法理解是哪一行代码或代码分支导致了错误。谁能帮我解决这个问题。UPDATE经过一番努力后,我陷入了这些问题。UPDATE谢谢大家的帮助。现在我只面临以下问题。很少有人要求发布源代码,但Xcode没有在页面上显示任何类型的警告或错误。泛型很少privateextensionArraywhereElement:IndexPath{funcindexOf(_indexPath:In

ios - Swift 3.0 迁移错误 : Type 'Element' constrained to non-protocol type 'IndexPath'

我正在尝试使用xCode将我的代码库迁移到swift3.0。有几个问题我无法理解。问题:类型“Element”被限制为非协议(protocol)类型“IndexPath”在错误导航面板的左侧,它仅显示错误下方。我无法理解是哪一行代码或代码分支导致了错误。谁能帮我解决这个问题。UPDATE经过一番努力后,我陷入了这些问题。UPDATE谢谢大家的帮助。现在我只面临以下问题。很少有人要求发布源代码,但Xcode没有在页面上显示任何类型的警告或错误。泛型很少privateextensionArraywhereElement:IndexPath{funcindexOf(_indexPath:In

swift - 制作一个键为 "Type"的 Swift 字典?

我正在尝试做这种事情..staticvarrecycle:[Type:[CellThing]]=[]但是-我不能:)Undeclaredtype'Type'在示例中,CellThing是我的基类,所以A:CellThing、B:CellThing、C:CellThing等等。我的想法是将各种AAA、BB、CCCC存储在字典数组中。如何使“类型”(我猜理想情况下,受限于CellThing)成为Swift字典中的键?我很感激我可以(也许?)使用String(describing:T.self),但这会让我失眠。这是一个用例,设想的代码看起来像这样......@discardableResu

swift - 制作一个键为 "Type"的 Swift 字典?

我正在尝试做这种事情..staticvarrecycle:[Type:[CellThing]]=[]但是-我不能:)Undeclaredtype'Type'在示例中,CellThing是我的基类,所以A:CellThing、B:CellThing、C:CellThing等等。我的想法是将各种AAA、BB、CCCC存储在字典数组中。如何使“类型”(我猜理想情况下,受限于CellThing)成为Swift字典中的键?我很感激我可以(也许?)使用String(describing:T.self),但这会让我失眠。这是一个用例,设想的代码看起来像这样......@discardableResu