草庐IT

non-recursive

全部标签

recursion - 在 Swift 应用程序中找不到内存泄漏

我正在尝试学习Swift,因此我为此编写了一个小测试应用程序。它只是给出目录中项目的总大小,递归到子目录中以累积其内容的总大小。该应用程序运行正常,但内存使用量在运行时不断增长。我曾预计内存使用会随着递归的深入而增加,并在递归调用返回时减少。相反,内存使用量不断攀升。仪器没有发现任何泄漏。我尝试了一些我在各种谷歌搜索结果中发现的技巧,包括:重新使用默认的NSFileManager不重新使用默认的NSFileManager而是为每个递归调用创建一个新的避免字符串插值似乎没有什么不同。我原以为Swift会在引用计数达到零时清理对象。这是当前状态下的完整代码:importFoundation

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

Swift 泛型 : Non-nominal type does not support explicit initialization

所以我试图理解通用协议(protocol)和类:protocolListPresenterTypewhereView.PDO.SW==Dispatcher.SW{associatedtypeDispatcher:ListDispatcherTypeassociatedtypeView:ListViewTypeinit(dispatcher:Dispatcher,state:@escaping(_state:AppState)->(ListState))funcattachView(_view:View)...}我从另一个通用类启动它:classAbstractListViewContr

ios - 错误 : UICollectionView must be initialized with a non-nil layout parameter

我正在尝试从youtube教程创建一个类似FacebookMessenger的应用程序。我有一个主页,用户可以在其中单击BarButton打开聊天。主页工作正常,直到我单击BarButton打开聊天,它崩溃并显示以下错误消息“必须使用非零布局参数初始化UICollectionView”。我是iOS开发的新手,所以无法真正理解问题出在哪里,因为我已经有了init方法。由于我有不同的观点,我是否在AppDelegate中遗漏了什么,这令人困惑:(。非常感谢您的帮助。谢谢!classChatViewController:UICollectionViewController,UICollect

Swift 协议(protocol)错误 : 'weak' cannot be applied to non-class type

Protocols和class-boundProtocols有什么区别,我们应该在Swift中使用哪一个?protocolA:class{...}protocolA{...}当协议(protocol)未定义为:class时尝试添加weak委托(delegate)时出现错误:protocolA{...}weakvardelegate:A给出错误:'weak'cannotbeappliedtonon-classtype或'weak'mustnotbeappliedtonon-class-bound'A';consideraddingaprotocolconformancethathasac

ios - 警告 : Unexpected version number in 'available' attribute for non-specific platform '*'

我有这段代码:@available(*,deprecated:3.0,message:"Useactivate().")publicfuncinstall(){self.activate()}自从我升级到swift5和xcode10.2之后,我收到以下警告:Unexpectedversionnumberin'available'attributefornon-specificplatform'*'并修复:Replace':3.0'with''这个警告是什么?它说什么? 最佳答案 documentation指出星号不能与Swift版本

ios - swift 错误 : '&' used with non-inout argument of type 'UnsafeMutablePointer'

我正在尝试从中转换以下Objective-C代码(source)-(CGRect)dimensionsForAttributedString:(NSAttributedString*)asp{CGFloatascent=0,descent=0,width=0;CTLineRefline=CTLineCreateWithAttributedString((CFAttributedStringRef)asp);width=CTLineGetTypographicBounds(line,&ascent,&descent,NULL);//...}进入swift:funcdimensionsFo

ios - ResponseSerializer 'cannot call value of non-function type ' NSHTTPURLResponse ?'' 与 Swift 3

在更新到Xcode8beta6之前,我一直在毫无问题地使用以下代码。它类似于thisexample来自Alamofire存储库。今天早上我将我的Alamofire库更新到最新的swift3分支,现在与beta6兼容。它显示错误:Cannotcallvalueofnon-functiontype'HTTPURLResponse?'存在类似问题here,但它不是基于当前版本的Swift和Alamofire。据我了解,这个错误是因为它认为我正在尝试返回Request属性(property)response而不是函数response(responseSerializer:,completion

ios - 错误 : Assigning non-escaping parameter 'publicationQuery' to an @escaping closure

我有一个像这样的ViewController:classPublicationListViewController:UIViewController{varpublicationQuery:(()->[Publication])!funcinitWith(title:String,publicationQuery:()->[Publication]){self.title=titleself.publicationQuery=publicationQuery}}为什么我会收到“将非转义参数‘publicationQuery’分配给@escaping闭包”错误?

swift - "Cannot call value of non-function type ' HTTPURL 响应? '"(Alamofire 4.0) [Swift 3.0]

我收到此错误:"Cannotcallvalueofnon-functiontype'HTTPURLResponse?'"关于部分:.response{(request,response,data,error)我想知道是否有人可以帮助我。Alamofire.download(urlToCall,method:.get){temporaryURL,responseinifFileManager.default.fileExists(atPath:finalPath!.path!){do{tryFileManager.default.removeItem(atPath:finalPath!.