- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我一直在这样说来形成 CGPoint 的 C 数组:
let arr = UnsafeMutablePointer<CGPoint>.allocate(capacity:4)
defer {
arr.deinitialize()
arr.deallocate(capacity:4)
}
arr[0] = CGPoint(x:0,y:0)
arr[1] = CGPoint(x:50,y:50)
arr[2] = CGPoint(x:50,y:50)
arr[3] = CGPoint(x:0,y:100)
现在(Xcode 9.3 beta 中的 Swift 4.1)deinitialize
和 deallocate(capacity:)
都被弃用了。看来我现在应该说的可能是:
defer {
arr.deinitialize(count:4)
arr.deallocate()
}
是这样吗?
最佳答案
是的,那是 SE-0184 Unsafe[Mutable][Raw][Buffer]Pointer: add missing methods, adjust existing labels for clarity, and remove deallocation size 的一部分,已在 Swift 4.1 中实现。
特别是:
Removing capacity from deallocate(capacity:) will end the confusion over what deallocate() does, making it obvious that deallocate() will free the entire memory block at self, just as if free() were called on it.
The old deallocate(capacity:) method should be marked as deprecated and eventually removed since it currently encourages dangerously incorrect code.
关于Swift 4.1 取消初始化和解除分配(容量 :) deprecated,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48570240/
如何确定操作表何时已关闭或已被驳回? 我关注了这个主题Fitting a UIDatePicker into a UIActionSheet并向操作表添加了选择器 View 。但是,当操作表仍处于打开
在关闭 UIActivityViewController 后如何调用操作?例如,如果我想在用户关闭 UIActivityViewController 后更改一段文本。 谢谢大家! 最佳答案 使用它的完
我的代码中有以下几行: func searchBarTextDidBeginEditing(searchBar: UISearchBar) { searchBar.showsCancelBut
像这样使用 UIAlertController 时: var alert = UIAlertController(title: "Core Location", message: "Loca
我正在使用 UITableViewController 来显示要编辑的项目列表。点击一行后,用户将转到 View Controller 以编辑数据。 当他们通过默认 <(后退)按钮退出编辑屏幕时,我想
我有一个自定义的 UIImagePickerController ,它工作得很好,只是我面临一个我认为应该相当简单的问题 - 我只是还没有找到解决方案。 触摸我自定义添加的“照片”按钮后,我将其定位到
我在显示 UIMenuController 的表格 View 单元格上实现了一个长按手势识别器,当菜单显示时,相应的表格 View 单元格被选中,这是我的要求。但问题是当我触及 UIMenuContr
我有: df = pd.DataFrame({'col1': ['asdf', 'xy', 'q'], 'col2': [1, 2, 3]}) col1 col2 0 asdf 1
我正在尝试解除实时事件的绑定(bind)(已尝试使用 .live 和 .delegate)。 当我想解除绑定(bind)时,我有 3 个不同的选项:解除绑定(bind) "click"、解除绑定(bi
我正在使用 spock、geb 和 WebDriver 编写测试脚本。该脚本在不安全的页面上提交表单。该页面提交到安全的 HTTPS URL。 Firefox 对此显示警告,特别是: 这会导致以下错误
我有两个 s 和每个 ng-repeat,但都对其子元素执行相同的操作,如下所示: {{item.name}} {{item.name}} 想象一下,有两种类型的数据集,要渲染
我构建了一个通过 APIHiJack 连接到 Win32 TextOut 函数的应用程序。当应用程序启动时,DLL 将按预期注入(inject),并且我的新 TextOut 函数被成功调用。 目前,关
我遇到了一次非常奇怪的崩溃,这是回溯。 * thread #1: tid = 0x2403, 0x3379516c CoreFoundation`CFHash + 8, stop reason = E
我有一个 FirstViewController 和一个 SecondViewController。它们的 UINavigationBar 有不同的颜色。当我显示 SecondViewControll
抱歉,如果我在文档中遗漏了一些内容,但无论如何我都找不到阻止在 SweetAlert 2 中关闭对话框的方法,这些将不起作用: await Swal.fire({
有没有人见过这个?在 iPad 模拟器中,我有一个 About View Controller 。我想以模态方式呈现它,并让用户单击关闭按钮。 更复杂的是,我有一个主视图 Controller ,它显
我有 3 个 View Controller - BaseViewController->AviewController->BviewController。 AviewController 以模态方式
如果我在对象上有一个事件聚合器, eventAggregator: _.extend({}, Backbone.Events), 对于模态视图,我基本上让模态视图的呈现者监听模态视图的事件。 this
我有几个 View Controller 。如果 Alert View 被确认,我需要返回到第一个 View Controller。如果没有 unwind Segue,我会这样做: @IBAction
我有一个为 SharePoint 编写的 Accordion 菜单: parent.click(function(event) { event.preventDefault(); va
我是一名优秀的程序员,十分优秀!