草庐IT

dex-method-counts

全部标签

ios - 如何导致NSString的dataUsingEncoding : method return nil?

我有一个方法(初始化程序)需要测试:publicconvenienceinit(jsonString:String,identifier:String,editable:Bool)throws{ifletdata=jsonString.dataUsingEncoding(NSUTF8StringEncoding){tryself.init(jsonData:data,identifier:identifier,editable:editable)}else{throwToggleSetJSONStringError.JSONStringEncodingError}}我必须编写一个单元测

ios - 更新到 Swift 2.0 'map' 不可用 : call the 'map()' method on the sequence

代码来自一个名为ZLBalancedFlowLayout的github控件。(link)。我一直在尝试更新到Swift2.0,但出现此错误“‘map’不可用:在序列上调用‘map()’方法”。任何意见将是有益的。提前谢谢你。privatefunccollectionView(collectionView:UICollectionView,framesForItemsInSectionsection:Int,inoutupdateContentSizecontentSize:CGSize)->([CGRect],[CGFloat]){letmaxWidth=Float(scrollDir

swift - FireStore Swift 4 : How to get total count of all the documents inside a collection, 并获取每个文件的详细信息?

我需要从super用户那里获取所有用户的数量,并在TableView中列出这些用户的详细信息。除了在firebase控制台中使用函数之外,是否有代码可以直接获取集合中的文档数。或遍历文档的简单查询! 最佳答案 这将收集所有文档并打印出来db.collection("superUsers").getDocuments(){(querySnapshot,err)inifleterr=err{print("Errorgettingdocuments:\(err)");}else{varcount=0fordocumentinquerySn

swift - 是否有一个 Swift 内置的默认字典,类似于 Array(repeating : 0, count : x)?

有没有办法创建默认字典来计算字符/字符串/其他?Python有方便的Counter()类,但我找不到任何Swift可以实例化任何东西的东西,类似于Array(repeating:0,count:x)。我知道我可以自己做。我在问Foundation中是否已经有类似的东西……因为我找不到它。谢谢!更新以下是最接近的两个答案:通过@mattlets="abracadabra"letletters=s.map{String($0)}varcountedLetters=[String:Int]()letters.forEach{countedLetters[$0,default:0]+=1}co

ios - 带有 Objective-C 选择器 'Method()' 的方法 'Method' 与具有相同 Objective-C 选择器的 'Method' 的 getter 冲突

自从更新到Xcode6.3后,我在我的一个扩展中遇到了这个问题......对于WKWebView..特别是在这些功能上。importUIKitimportWebKitextensionWKWebView:MyWebViewProvider{//Method'URL()'withObjective-Cselector'URL'conflictswithgetterfor'URL'withthesameObjective-CSelectorfuncURL()->NSURL?{returnself.URL}//Method'canGoBack()'withObjective-Cselecto

ios - 无法生成具有旧节数 : 1 and new section count: 0 with FetchedResultsController 的新节图

在我的ViewController中,我有一个已实现的fetchedResultsController并且一切正常(显示行、多个部分、获取等)。但是当我尝试更新或删除部分中的最后一行时出现错误(当我说“最后一行”时,我的意思是该部分中只剩下一行)。如果该部分中有不止一行,当我更新它的值(在CoreData中)时,它不会发生任何错误。我读过this,this和this但它对我没有帮助(解决方案已过时),而且我还没有在StackOverflow和互联网上找到任何解决我的问题的方法。我需要帮助。我正在使用Xcode8.3.3和Swift3。这是我在尝试更新tableView的任何部分中的“唯

ios - 如何以编程方式设置 UILabels 的约束,其中 Label Count 等于 Swift 中的主屏幕高度

我想创建这个格式label1|label2|label3|label4label5|label6|label7|其中标签计数等于View高度。并且还想设置约束。下面的代码是创建UILabels:foriin0...Int(self.view.frame.height){letlabel=UILabel(frame:CGRect(x:0,y:0,width:50,height:50))label.textAlignment=NSTextAlignment.centerlabel.text="label"label.sizeToFit()self.view.addSubview(label

iOS : push notification badge count not increase in this payload formate

当应用程序在后台正常运行时,时间角标(Badge)计数未在最后5天前设置。角标(Badge)计数每次由php后端ex增加。当前角标(Badge)=10然后在第二次推送后得到然后角标(Badge)=11我正在使用波纹管有效载荷甲酸盐。如果波纹管甲酸盐有任何变化,请帮助我,我也阅读了ApplePushNotificationService.推送通知负载是一个JSON负载:{"aps":{"badge":10,"alert":"Helloworld!","sound":"cat.caf"}}registerUserNotificationSettingsif(ios8){if([applic

iOS 并发问题 : method returned before got the pedometer data

像下面的代码,当我想通过一个方便的方法返回一个计步器数据时,但是方法返回早于数据被检索。我认为这可能是一个并发问题。如何以正确的方式返回数据以供将来使用?ThxfuncqueryPedometerTodayTotalData()->Int{varpedometerDataOfToday:CMPedometerData?self.queryPedometerDataFromDate(NSDate.today()!,toDate:NSDate(),withHandler:{(pedometerData,error)inpedometerDataOfToday=pedometerData!p

ios - Swift addSubview() 在使用 init 创建的 View 上(重复 :count) doesn't work

这是一个使用init(repeating:count)创建4个subview的ViewController。在viewDidLoad中,我将它们添加为subview并设置它们的框架。当我运行应用程序时,只添加了最后一个View。classViewController:UIViewController{letsubviews=[UIView].init(repeating:UIView(),count:4)overridefuncviewDidLoad(){super.viewDidLoad()foriin0..这是相同的代码,除了我使用的不是init(repeating:count)关