草庐IT

gravity_value_t

全部标签

ios - Swift 编译器 : cannot subscript a value of type '[NSObject]' with an index of type '()'

关闭。这个问题是notreproducibleorwascausedbytypos.它目前不接受答案。这个问题是由于错别字或无法再重现的问题引起的。虽然类似的问题可能是on-topic在这里,这个问题的解决方式不太可能帮助future的读者。关闭7年前。Improvethisquestion场景:第1步:第2步:第3步:问题总结:我开始使用swift及其基本概念。首先,我尝试用多个不同类型的元素制作一个数组ab(不确定它是否应该被称为数组)。然后我尝试测试一个索引值ab[2]。成功测试索引值后,我制作了一个字典dictAbc,其中我使用不同的索引ab[4]ab[6]指向到它的键。它引入

ios - Swift 2.2 语法错误 : Cannot call value of non-function type 'UITableView!'

我在UITableView单元格中使用Tab手势,但出现以下错误。“无法调用非函数类型‘UITableView!’的值!”我正在使用从我以前的ObjectiveC项目继承的以下代码:varp:CGPoint=sender.locationInView(self.tableView)varindexPath:NSIndexPath=self.tableView(forRowAtPoint:p)varbuttonTag:Int=indexPath.rowvarselectView=self.storyboard?.instantiateViewControllerWithIdentifie

ios - swift 3.0 : Value of type 'IndexSet' has no member 'enumerateIndexesUsingBlock'

接收“IndexSet”类型的值在enumerateIndexesUsingBlock处没有成员“enumerateIndexesUsingBlock”错误。/**Extensionforcreatingindexpathsfromanindexset*/extensionIndexSet{/**-parametersection:ThesectionforthecreatedNSIndexPaths-return:AnarraywithNSIndexPaths*/funcbs_indexPathsForSection(_section:Int)->[IndexPath]{varind

ios - 你如何使用 perform(#selector(setter :)) to set the value of a property using swift 4?

我正在尝试运行这段代码,但它产生了意想不到的结果。classTest:NSObject{@objcvarproperty:Int=0}vart=Test()t.perform(#selector(setter:Test.property),with:100)print(t.property)正在打印的值是一些垃圾号码-5764607523034233277。如何使用perform方法设置属性的值? 最佳答案 performSelector:withObject:方法需要一个对象参数,因此Swift将基本类型100转换为对象引用。se

ios - fatal error : unexpectedly found nil while unwrapping an Optional value (lldb)

overridefuncprepareForSegue(segue:UIStoryboardSegue,sender:AnyObject!){ifsegue.identifier=="showLocalMenuDetail"{ifletindexPath=self.tableView.indexPathForSelectedRow(){self.slideMenuController()?.closeLeft()letdestinationController=segue.destinationViewControllerasDetailViewControllerdestinatio

arrays - 选择要附加到三元运算符 'if' 运算符 : "Immutable value... only has mutating members" 的数组

我有两个数组:varaddedToIgnoreList:[String]=[]varremovedFromIgnoreList:[String]=[]我想将一个值附加到这些数组之一。如果我这样做:(isUserIgnored?removedFromIgnoreList:addedToIgnoreList).append("username")我得到Immutablevalueoftype'[String]'onlyhasmutatingmembersnamed'append'如果我使用中间变量,它会起作用:varwhich=isUserIgnored?removedFromIgnore

ios - 准备 segue : Cannot convert value of type 'UIViewController' to specified type 'SecondViewController'

我知道我肯定在这里遗漏了一些明显的东西,但我似乎无法通过它的实际类型来引用目标ViewController。我按照以下步骤从头开始创建了一个新项目来对此进行测试:创建一个新的单View应用程序项目添加一个新的ViewController创建一个新类,子类化UIViewController,并将其命名为SecondViewController将这个新类设置为第二个ViewController的自定义类(现在它的标题是第二个ViewController)向第一个ViewController添加一个按钮,然后按住Ctrl键单击它到第二个ViewController,然后从ActionSegu

ios - swift 2 : Cannot subscript a value of type '[GKScore]?'

让highscore=leaderboardRequest.scores[0]为!GKScore结果为无法下标“[GKScore]”类型的值?Swift2中正确的语法是什么 最佳答案 leaderboardRequest.scores未解包,使用下标前解包。ifletscores=leaderboardRequest.scores{iflethighscore=scores.firstas?GKScore{//safelyuse`highscore`here}}“展开”是Swift中的一个关键概念,它与Optionals一起出现。[

ios - swift 3.1 : Cannot convert value of type '(_) -> ()' error/Problems with closures

我升级到Swift3.1,我收到了一些新错误,这些错误似乎是3.1语法问题,因为在迁移之前它们不是问题。它们大多与闭包有关,如本例所示:letalert=UIAlertController(title:"Success",message:"Thanksforparticipatinginourraffle!",preferredStyle:UIAlertControllerStyle.alert)alert.addAction(UIAlertAction(title:"OK",style:.default,handler:{performSegue(withIdentifier:"to

objective-c - fatal error : unexpectedly found nil while unwrapping an Optional value, 快速获取 json 错误

获取json错误当我尝试返回json时,出现错误fatalerror:unwrappedlyfoundnilwhileunwrappinganOptionalvalue:funcgetJson(str:NSString)->AnyObject{varproxiesURL=NSURL(string:str)varproxiesDataJson=NSData.dataWithContentsOfURL(proxiesURL,options:NSDataReadingOptions.DataReadingUncached,error:nil)varjson:AnyObject!if(prox