- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我之前创建了一个 ObjC 类。我怎样才能再次删除它?因为在以后的某个时候,我想用另一个版本重新创建它。
现在,如果我只是重新声明它,我会收到异常 X is overriding existing Objective-C class
.
最佳答案
我不知道如何在 PyObjC 中执行此操作,但是执行此操作的 Objective-C 运行时函数应该是 objc_disposeClassPair()
.稍微搜索了一下,表明使用此 Objective-C 运行时功能可能无法在 PyObjC 中工作:
2008 年 1 月的 PyObjC SVN 提交消息如下:Initial attempt of using objc_disposeClassPair. Disabled because this causes an unexpected crash.
http://blog.gmane.org/gmane.comp.python.pyobjc.cvs/month=20080101
有问题的代码仍然在 PyObjC 源代码的当前 class-builder.m 中的第 164ff 行,并以一个有趣的注释为前缀:
/*
* Call this when the python half of the class could not be created.
*
* Due to technical restrictions it is not allowed to unbuild a class that
* is already registered with the Objective-C runtime.
*/
int
PyObjCClass_UnbuildClass(Class objc_class __attribute__((__unused__)))
{
PyObjC_Assert(objc_class != nil, -1);
PyObjC_Assert(objc_lookUpClass(class_getName(objc_class)) == nil, -1);
//objc_disposeClassPair(objc_class);
return 0;
}
关于objective-c - PyObjC:如何删除现有的 Objective-C 类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7361847/
我不小心安装了 pyobjc 2.2 和 easy-install pyobjc,这导致了问题:当我尝试导入它时出现错误 Incompatible library version: _objc.so
我构建了一个 pyobjc 应用程序,发现它似乎需要很长时间才能加载。 我添加了日志记录来测量加载每个步骤所需的时间。在进入 AppHelper.runEventLoop() 之前,应用程序需要花费
我正在尝试使用 PyObjC 制作一个应用程序,并且正在努力寻找如何记录箭头键(向左和向右)。我希望能够记录用户每次按下左右箭头键的时间。我正在使用网上找到的另一个例子。我想使用键盘上的箭头键,而不是
编辑:感谢您的建议。我仍然不清楚自动释放池的实际处理方式。 这是实际的代码: import platform, time if (platform.system().lower() == "darwi
我已经在 Mac 上安装了 PyObjC,但我根本无法让它工作。即使尝试导入 AddressBook 类也会立即失败。 Python 2.7.2 (v2.7.2:8527427914a2, Jun 1
我理解 PyObjC 的概念,但找不到任何关于它到底是什么或如何开始使用它的信息。 它是否像一个转换器,您可以在其中输入 python 文件并获得一个 objective c 文件?或者它是一个你可以
Xcode最强大的功能之一就是Intellisense completion,当您键入Foundation/Cocoa/UIKit API的名称时,它会弹出一个潜在候选列表。我对MacRuby,PyO
我正在使用此层次结构在 PyObjC 中以编程方式创建一个菜单。 NSMenu (setMainMenu on NSApplication) - NSMenuItem(1) - NSMenu: "
官方文档说可以在Python代码中使用自定义 block ,但需要创建元数据。我还没有找到这样的例子。 我的问题是如何创建、使用和分发自定义 block 的元数据。 示例 @interface Som
我正在尝试为 NSWebView 实现一个委托(delegate),但是当我运行它时,我得到了这个错误: TypeError: Error when calling the metaclass bas
当我在 pyObjC 代码中调用 setDelegate_ 时,我收到 AttributeError: 'tuple' object has no attribute 'setDelegate_'。
我正在尝试根据 the KVC guide 在 Python 中为我的模型类实现索引访问器方法。 .出于性能原因,我想使用可选的范围方法一次加载多个对象。该方法采用指向 C 数组缓冲区的指针,我的方法
在 OSX Maverick 上,我有这个基于 PyObjC(python3.3) 的简单 APP test.py class MyDelegate(NSObject): def applicatio
我正在学习如何使用 pyobjc 进行一些基本原型(prototype)制作。现在我有一个主 UI 设置和一个运行主应用程序的 python 脚本。唯一的问题是当脚本运行时,脚本在主线程上运行从而阻塞
如何使用 PyObjC 获取全局滚动事件?可以通过 NSEvent 调用来完成吗? 示例代码会很棒... 最佳答案 您的 NSEvent 走在正确的轨道上!只要您不想修改事件,而只是观察它,就像调用
我正在尝试在 Cocoa PyObjc 项目中使用来自 BWToolkit 的 Brandon Walkin 的 BWSplitView。当我运行该项目时,我收到以下错误消息: NSInvalidUn
我正处于开发跨平台(Mac 和 Windows)应用程序的规划阶段。性能不是问题,Python 非常适合问题领域。我是一名具有 pyojc 经验的 Cocoa 开发人员。 Cocotron 看起来很吸
我想为我正在设计的应用程序使用 NSOpenPanel。这是我到目前为止所拥有的: @objc.IBAction def ShowOpenPanel_(self, sender): self.
关闭。这个问题是opinion-based .它目前不接受答案。 想要改进这个问题吗? 更新问题,以便 editing this post 提供事实和引用来回答它. 关闭 9 年前。 Improve
我将在 Mac App Store 中销售一个使用该框架的程序。我想确保它能得到 Apple 的批准。 最佳答案 是的。 $ /usr/bin/python2.6 Python 2.6.1 (r261
我是一名优秀的程序员,十分优秀!