草庐IT

understanding-weak-references

全部标签

ios - 在扩展中创建便利 init 时为 `Ambiguous reference to member`

这是我的init:extensionNSNumberFormatter{convenienceinit(digits:Int=0){self.init()//ambiguousreferencetomember'NSNumberFormatter.init'groupingSeparator=""decimalSeparator="."numberStyle=.DecimalStyleroundingMode=.RoundHalfDownmaximumFractionDigits=digitsminimumFractionDigits=digits}}这是什么原因?同样的问题是当我将s

ios - 在扩展中创建便利 init 时为 `Ambiguous reference to member`

这是我的init:extensionNSNumberFormatter{convenienceinit(digits:Int=0){self.init()//ambiguousreferencetomember'NSNumberFormatter.init'groupingSeparator=""decimalSeparator="."numberStyle=.DecimalStyleroundingMode=.RoundHalfDownmaximumFractionDigits=digitsminimumFractionDigits=digits}}这是什么原因?同样的问题是当我将s

弱监督语义分割(Weakly-Supervised Semantic Segmentation)

语义分割(SemanticSegmentation)语义分割是指将图像中的每个像素分类为一个实例,其中每个实例都对应于一个类。这项技术一直是计算机视觉图像领域的主要任务之一。而在实际应用中,由于能准确地定位到物体所在区域并以像素级的精度排除掉背景的影响,一直是精细化识别、图像理解的可靠方式。而构建语义分割数据集需要对每张图像上的每个像素进行标注,所需要的人力物力让实际业务项目投入产出比极低。(像素级标注)针对这个问题,仅需图像级标注即可达到接近的分割效果的弱监督语义分割是近年来语义分割相关方向研究的热点。弱监督语义分割(Weakly-SupervisedSemanticSegmentation

ios - swift 错误 : Reference to generic type Dictionary requires arguments in <. ..>

错误ReferencetogenerictypeDictionaryrequiresargumentsin出现在函数的第一行。我试图让函数返回从api检索到的NSDictionary。有人知道这里会发生什么吗?classfuncgetCurrentWeather(longitude:Float,latitude:Float)->Dictionary?{letbaseURL=NSURL(string:"https://api.forecast.io/forecast/\(apikey)/")letforecastURL=NSURL(string:"\(longitude),\(latit

ios - swift 错误 : Reference to generic type Dictionary requires arguments in <. ..>

错误ReferencetogenerictypeDictionaryrequiresargumentsin出现在函数的第一行。我试图让函数返回从api检索到的NSDictionary。有人知道这里会发生什么吗?classfuncgetCurrentWeather(longitude:Float,latitude:Float)->Dictionary?{letbaseURL=NSURL(string:"https://api.forecast.io/forecast/\(apikey)/")letforecastURL=NSURL(string:"\(longitude),\(latit

ios - Swift 闭包 [weak self] 和异步任务

想象一种情况,当您想要从服务器异步加载一些文本并将结果显示在ViewController的UITextField。dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,0),{//...somelongrunningasyncoperationiflettextResponse=responseFromServer{dispatch_async(dispatch_get_main_queue(),{[weakself]()inself?.textField.text=textResponse})

ios - Swift 闭包 [weak self] 和异步任务

想象一种情况,当您想要从服务器异步加载一些文本并将结果显示在ViewController的UITextField。dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,0),{//...somelongrunningasyncoperationiflettextResponse=responseFromServer{dispatch_async(dispatch_get_main_queue(),{[weakself]()inself?.textField.text=textResponse})

ios - 为什么初始化为 `weak` 在 Swift 中返回 `nil`?

为什么对weakvar的初始化返回变量为nil而对通常的var的初始化返回预期结果?在ViewController.swift的以下代码中:weakvarmyButton:UIButton!varmyButtonNotWeak:UIButton!overridefuncviewDidLoad(){letframe=CGRect(x:0,y:0,width:100,height:100)myButton=UIButton(frame:frame)myButtonNotWeak=UIButton(frame:frame)print("\(myButton),\(myButtonNotWea

ios - 为什么初始化为 `weak` 在 Swift 中返回 `nil`?

为什么对weakvar的初始化返回变量为nil而对通常的var的初始化返回预期结果?在ViewController.swift的以下代码中:weakvarmyButton:UIButton!varmyButtonNotWeak:UIButton!overridefuncviewDidLoad(){letframe=CGRect(x:0,y:0,width:100,height:100)myButton=UIButton(frame:frame)myButtonNotWeak=UIButton(frame:frame)print("\(myButton),\(myButtonNotWea

swift - RXSwift 闭包中的“[weak self]”

我需要在RXSwiftsubscribeNext闭包中使用[weakself]吗?我有代码:searchController.searchBar.rx_text.throttle(0.2,scheduler:MainScheduler.instance).subscribeNext{searchTextinself.viewModel.searchForLocation(searchText)}.addDisposableTo(DisposelBag.sharedDisposelBag.disposeBag)我是否需要修改它以便在闭包的开头有一个[weakself]捕获列表?像这样:s