草庐IT

current_index

全部标签

ios - 为什么 Locale.current.identifier 无效?

当设置“语言和地区”(设置=>通用=>语言和地区)时出现问题,如下所示:“iPhone语言”到“英语(加拿大)”。“地区”到“约旦”。但是,(如提到的答案:Howtogetdetailedlanguageofdeviceinswift调用:print(Locale.current.identifier)日志:en_JO这是一个无效localidentifier(按理来说,约旦是一个中东国家,母语是阿拉伯语,不是英语)。我还检查了availableIdentifiers:print(Locale.availableIdentifiers)而且-显然-它不包含“en_JO”。另外,我试过:

arrays - Swift - 追加对象 : array index out of range

当我尝试将一个项目添加到我的数组时,它给我和EXCBADInstruction错误,它说fatalerror:Arrayindexoutofrange这是代码:vartabelle:[[Actions]]=[[]]funcdoSomething(){varresults=self.fetch()varoldProjektName:String=results[0].projektNamevarcount:Int=0foriteminresults{ifoldProjektName==item.projektName{tabelle[count].append(item)}else{co

ios - `UTF16Index()` 或 `UTF16Index.init(encodedOffset:)` 用于 Xcode 8/9 支持

我所在的开发团队同时支持Xcode8和Xcode9。我正在开发一个在Xcode8中使用String.UTF16Index(range.location)的功能。当我升级到Xcode9时,导致错误'init'isdeprecated.所以在Xcode9中我将其更改为UTF16Index.init(encodedOffset:range.lowerBound)。但是,现在这在Xcode8中不起作用,出现错误Argumentlabels'(encodedOffset:)'donotmatchanyavailableoverloads。即使我可以检查Xcode版本并编写不同的代码,其中一行也会

ios - "Index Out Of Range"刷新表时 - Swift

我在ViewController中有两个按钮,在它们下面有一个表格View。当使用不同的过滤器参数按下两个按钮之一时,表格View将被刷新。实际上,当加载表格View然后单击另一个按钮时,它工作正常并且表格被刷新。但是,当您在表格View中滚动并且滚动仍在发生时,您按下另一个按钮,我收到“索引超出范围”错误。尝试了很多事情来解决它,但就是做不到。有任何想法吗?我使用parse作为免费成员(member)。我的代码的重要部分如下:@IBActionfuncfilterType0_clicked(sender:AnyObject){iffilterTypeVar!=0{self.activ

swift - 'for index'与传统 'for loop'的区别

我是Swift的新手,也是编程新手。我不确定是不是因为现在是凌晨2点34分,但有人可以帮我确定这两个循环之间的区别吗?第一个是产生我想要的值但使用(正如Swift文档所解释的那样)一个“传统的C循环”,其中后一个是使用Swift首选的“forindex”循环(我个人喜欢因为我更清楚),问题是这个循环返回每个数字而不是满足条件。funcfindLargestPrimeFactor(number:Int){forvari=2;i0{}else{print(i);}}}findLargestPrimeFactor(13195);下面是将每个数字返回到13195funcfindLargestP

xcode - iOS8.0 的 CompileSwift 状态为 "the current deployment target does not support automated __weak references"

我正努力在Swift应用程序中使用静态库(从ObjectiveC编译)。我有一个包含相关header的ObjectiveC桥接header。构建应用程序时出现此错误../someDirectory/Xcode/FirstSteps/headers/Acme.h:89:thecurrentdeploymenttargetdoesnotsupportautomated__weakreferencesAcme类确实使用弱引用,但部署目标是iOS8.0,它应该支持它们。我是不是找错树了?Acme.h的第89行显示:-(void)addTopicListener:(__weakNSObject*

ios - swift fatal error : array index out of range

我正在制作一个待办事项列表应用程序,但是当我尝试从我的列表中删除某些内容时,xcode给我一个错误,提示“fatalerror:数组索引超出范围”。有人可以告诉我我的数组做错了什么导致发生这种情况吗?importUIKitclassSecondViewController:UIViewController,UITableViewDelegate,UITableViewDataSource{overridefuncviewDidLoad(){super.viewDidLoad()//Doanyadditionalsetupafterloadingtheview,typicallyfrom

ios - 苹果 swift : how to get current seconds in 1/100 or 1/1000?

funcupdateTime(){vardate=NSDate()varcalendar=NSCalendar.currentCalendar()varcomponents=calendar.components(.CalendarUnitSecond,fromDate:date)varhour=components.hourvarminutes=components.minutevarseconds=components.secondcounterLabel.text="\(seconds)"varmyIndicator=counterLabel.text?.toInt()ifmyI

ios - 如何为 UITableView 中的 Index Bar 部分设置透明背景?

如何在UITableView中为sectionsindexbar设置透明背景?我试过:tableView.sectionIndexBackgroundColor=.clearColor()但是栏的背景是浅灰色编辑我尝试更改tableview的背景颜色,但它似乎没有影响。tableView.backgroundView=UIView.init()tableView.backgroundColor=.blackColor()//tried.clearColor()too.EDIT2tableView.sectionIndexBackgroundColor=UIColor(white:CGF

ios - 'Int' 与 'String.Index' 不同

作为练习,我正在使用Swift重写我的一个应用。在Objective-C中,我有以下代码行:NSRangeextendedRange=NSUnionRange(range,[[self.backingStorestring]lineRangeForRange:NSMakeRange(NSMaxRange(range),0)]);在swift中它看起来像这样:letstr=backingStore.stringletextendedRange:NSRange=NSUnionRange(range,str.lineRangeForRange(NSMakeRange(NSMaxRange(r