草庐IT

question_type

全部标签

ios - swift 错误 : Value of type 'NSObject -> () ' AnimalListTableViewController' has no member 'tableView'

我正试图在swiftxcode中消除这些错误如果截图太小,这里是代码importUIKitclassAnimalListTableViewController:UITableViewController{overridefunctableView(tableView:UITableView,numberOfRowsInSectionsection:Int)->Int{return4}letindexPath=self.tableView.indexPathForSelectedRow()//thisiswheretheerrorappears,itsaysValueoftype'NSO

swift 2 : Cannot convert value of type '[NSObject : AnyObject]' to expected argument type '[String : AnyObject]'

我有一个用Swift1构建的项目。但是在自动转换为Swift2后,它显示错误:无法将类型'[NSObject:AnyObject]'的值转换为预期的参数类型'[String:AnyObject]'。函数代码:funccreateViewContainers()->NSDictionary{varcontainersDict=NSMutableDictionary()letitemsCount:Int=tabBar.items!.countasInt-1forindexin0...itemsCount{varviewContainer=createViewContainer()conta

ios - swift 错误 : Could not cast value of type 'NSTaggedPointerString' (0x1a1264378) to 'NSNumber' (0x1a126f900)

我在Xcode(swift)中遇到这个错误:Couldnotcastvalueoftype'NSTaggedPointerString'(0x1a1264378)to'NSNumber'(0x1a126f900).我用//ERROR:("...")明确了错误在哪里代码:importUIKitimportiAdimportAVFoundationimportAudioToolboxletMAX:UInt32=4letMIN:UInt32=1classViewController:UIViewController,ADBannerViewDelegate{varchances=10varw

cvc-complex-type.2.4.a: 发现了以元素 ‘base-extension‘ 开头的无效内容。应以 ‘{layoutlib}‘ 之一开头

最近,在使用最新版的AndroidStudio打开一个两年前的项目时候,报了一个如下的错误:【cvc-complex-type.2.4.a:发现了以元素‘base-extension‘开头的无效内容】。应以‘{layoutlib}‘之一开头。之所以出现上面的错误,官方的解释是:【跟随ArcticFox更新的其中一个重点就是AGP7.0的调整…使用AndroidGradleplugin7.0构建时需要JDK11才能运行Gradle…并且只要你更新到AndroidStudioArcticFox,它是直接捆绑了JDK11并将Gradle配置为默认使用它,所以大多数情况下,如果你本地配置正常,是可以直

swift - 错误 : cannot convert value of type '() -> ()' to closure result type 'String' using Swift + PromiseKit

我不熟悉Swift中的promise,并使用PromiseKit尝试在Playground上创建一个非常简单的响应并尝试使用它。我有以下代码:importUIKitimportPromiseKitfuncfoo(_error:Bool)->Promise{returnPromise{fulfill,rejectinif(!error){fulfill("foo")}else{reject(Error(domain:"",code:1,userInfo:nil))}}}foo(true).then{response->Stringin{print(response)}}但是我得到以下错误

swift - 为什么代码会产生错误 Type '(int, int)' does not conform to protocol 'IntegerLiteralConvertible'

使用下面的代码,我得到“Type'(int,int)'doesnotconformtoprotocol'IntegerLiteralConvertible'insteadofmissingargument正如人们所期望的那样。什么是IntegerLiteralConvertible以及为什么您认为编译器会产生此错误而不是下面的代码?我查看了有关此错误的其他SO帖子,但没有从中得到任何见解。funcadd(x:Int,y:Int){}add(3) 最佳答案 我最好的猜测是它试图将(3)元组转换为(Int,Int)元组。事实上,这被编译

ios - iTunes 连接 : Invalid Swift Support - framework doesn’t have the correct file type for this location

我目前正在使用Xcode7.1.1将我的应用上传到应用商店但是当我上传我的应用程序时,我收到了来自Apple的电子邮件。Deardeveloper,Wehavediscoveredoneormoreissueswithyourrecentdeliveryfor"****".Toprocessyourdelivery,thefollowingissuesmustbecorrected:InvalidSwiftSupport-Thefile****.app/Frameworks/JSQSystemSoundPlayer.framework,****.app/Frameworks/JLToa

Swift 样式 : Function returns optional of type that you need in order to continue, 处理此问题的最佳做法是什么?

首先,我将使用cellForRowAtIndexPath作为我的示例,因为出队函数返回一个可选的并且忽略显式解包它是完全安全的事实。我的问题是:什么被认为是“最佳”方式或风格来处理您调用返回可选的函数但您需要从该函数返回以继续操作的情况。我发现第一个片段非常笨拙和丑陋:iflettheCell=UITableView().dequeueReusableCellWithIdentifier("cell"){setUpCell(theCell)returntheCell}else{lettheCell=UITableViewCell(style:.Default,reuseIdentifi

IOS FoodTracker 教程 : Value of tuple type '()' has no member 'path'

我正在完成IOSSwift教程“FoodTracker”,但是有一个错误我可以找到解决方案,但我不明白哪里出了问题以及如何解决它:错误:Valueoftupletype'()'hasnomember'path'此错误在以下代码中针对变量“Meal.ArchiveUrl.path”显示。我的代码,在MealtableViewController(相当于IOS教程):privatefuncsaveMeals(){letisSuccessfulSave=NSKeyedArchiver.archiveRootObject(meals,toFile:Meal.ArchiveUrl.path)if

ios - "type of expression is ambiguous without more context"- 引用 appDelegate

我的appDelegate最初是用Obj-C编写的。我试图在一个新的Swift类中访问它,但我遇到了一个我认为具有误导性的奇怪错误,我正试图找到根源。在我的Swift文件中,我在以下位置设置了一个断点:varappDelegate=UIApplication.sharedApplication().delegate如果我只是po:poappDelegate我得到:PrintingdescriptionofappDelegate:Optional()一切都很好。但是,当我尝试:poappDelegate.navigationController在调试控制台中我得到:error::1:13