Can you help me solve the problem about object_c? I'm using objc_util() to create a UIDragInteraction, but it didn't work. The error message is like this.
This is my code and error message.What I ultimately want to accomplish is to implement UIDragInteraction and UIDropInteraction operations in pythonista ui view.
The error message is:
Traceback (most recent call last):
File "_ctypes/callbacks.c", line 259, in 'converting callback result'
TypeError: cannot be converted to pointer
# coding: utf-8
from objc_util import *
import ui
def dragInteraction_itemsForBeginningSession_(_m,_c,interaction,session):
provider=ObjCClass('NSItemProvider').alloc().initWithObject('i am string')
item=ObjCClass('UIDragItem').alloc().initWithItemProvider(provider)
nsarry=ObjCClass("NSArray").arrayWithObject(item)
return nsarry
methods=[dragInteraction_itemsForBeginningSession_]
protocols=['UIDragInteractionDelegate']
draginter=create_objc_class('itemsForBeginningSession',methods=methods,protocols=protocols)
@on_main_thread
def create_drag(f_v):
ob_fv=ObjCInstance(f_v)
f=CGRect(CGPoint(100,100 ), CGSize(300, 300))
ob_cv=ObjCClass("UIView").alloc().initWithFrame(f)
color=ObjCClass('UIColor').colorWith(red=1.0, green=0.0, blue=0.0, alpha=1.0)
ob_cv.setBackgroundColor(color)
delegate=draginter.alloc().init()
obj_draginter=ObjCClass('UIDragInteraction').alloc().initWithDelegate(delegate)
obj_draginter.setEnabled(True)
ob_cv.addInteraction(obj_draginter)
ob_fv.addSubview(ob_cv)
cui=ui.View(bg_color='#ffffff',farme=(0,0,500,500))
create_drag(cui)
cui.present()