Python 和 Objective-C 的交互接口 PyObjC

码农软件 · 软件分类 · Python开发工具 · 2019-11-13 17:13:14

软件介绍

PyObjC 旨在为 Python 和 Objective-C 两种语言之间提供交互的接口。Python 语言可以通过PyObjC来使用已有的Objective-C的代码,反过来Objective-C也可以利用Python语言的一些功能。

PyObjC最主要的用处是在 Mac OS X 系统下使用纯Python语言来开发 Cocoa GUI 应用程序。

 示例代码:

class MyClass(NSObject):

   def init(self):
       """
       Designated initializer for MyClass
       """
       # ALWAYS call the super's designated initializer.
       # Also, make sure to re-bind "self" just in case it
       # returns something else, or even None!
       self = objc.super(MyClass, self).init()
       if self is None: return None

       self.myVariable = 10

       # Unlike Python's __init__, initializers MUST return self,
       # because they are allowed to return any object!
       return self


class MyOtherClass(MyClass):

   def initWithOtherVariable_(self, otherVariable):
       """
       Designated initializer for MyOtherClass
       """
       self = objc.super(MyOtherClass, self).init()
       if self is None: return None

       self.otherVariable = otherVariable
       return self

myInstance = MyClass.alloc().init()
myOtherInstance = MyOtherClass.alloc().initWithOtherVariable_(20)

本文地址:https://codercto.com/soft/d/18913.html

人工智能时代

人工智能时代

[ 美]杰瑞•卡普兰(Jerry Kaplan) / 李盼 / 浙江人民出版社 / 2016-4-1 / CNY 59.90

 当机器人霸占了你的工作,你该怎么办?机器人犯罪,谁才该负责?人工智能时代,人类价值如何重新定义?  在《人工智能时代》一书中,智能时代领军人、硅谷连续创业者杰瑞·卡普兰指出:智能时代的到来,给人类社会带来了两大灾难性冲击:持续性失业与不断加剧的贫富差距。机器正在很大程度上替代人类的工作,不管你是蓝领还是白领。而针对未来社会将要发生的这些问题,卡普兰在《人工智能时代》一书中从企业、税收和......一起来看看 《人工智能时代》 这本书的介绍吧!

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具