无法在pyObjC中的对象上调用方法 [英] Can't call methods on objects in pyObjC

查看:113
本文介绍了无法在pyObjC中的对象上调用方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在pyObjC代码中调用setDelegate_时,会得到一个AttributeError: 'tuple' object has no attribute 'setDelegate_'.

When I call setDelegate_ within my pyObjC code I get an AttributeError: 'tuple' object has no attribute 'setDelegate_'.

我的代码如下:

def createMovie(self):
        attribs = NSMutableDictionary.dictionary()
        attribs['QTMovieFileNameAttribute'] = '<My Filename>'
        movie = QTMovie.alloc().initWithAttributes_error_(attribs, objc.nil)
        movie.setDelegate_(self)

修改

我发现我不能对movie对象使用任何实例方法.

I Found out that i can't use any instance methods with the movie object.

推荐答案

从您的评论看来,QTMovie.alloc().initWithAttributes_error_实际上返回了一个由两个元素组成的元组,其中您想要的对象作为第一个元素,而其他对象则作为第二个元素元素(可能是错误?)

From your comment, it looks like QTMovie.alloc().initWithAttributes_error_ actually returns a two-element tuple, with the object you want as first element and some other object in the second element (possibly an error ?)

您应该能够像这样访问对象:

You should be able to access your object like that:

(movie, error) = QTMovie.alloc().initWithAttributes_error_(attribs, objc.nil)

这篇关于无法在pyObjC中的对象上调用方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆