我想通過PyObjC訪問我的iPhone的加速度計。 這裏是我的代碼:使用PyObjC訪問iPhone加速度計
@objc.signature("[email protected]:@@")
def accelerometer_didAccelerate_(self, accelerometer, acceleration):
msgBox = UIAlertView.alloc().initWithTitle_message_delegate_cancelButtonTitle_otherButtonTitles_("Acceleration", str(acceleration.x), self, "OK", None)
msgBox.show()
msgBox.release()
@objc.signature("[email protected]:@")
def applicationDidFinishLaunching_(self, unused):
self.accelerometer = UIAccelerometer.sharedAccelerometer()
self.accelerometer.setUpdateInterval_(1)
self.accelerometer.setDelegate_(self)
#...
問題是STR(accelleration.x)返回"<native-selector x of <UIAcceleration: 0x.....>>"
。我能做什麼?