KeyError at field_list.append()
freemant2000 opened this issue · 1 comments
freemant2000 commented
I am trying to use pyobjus to access the view with the following code:
logging.debug("getting UIApplication")
app_cls=autoclass("UIApplication")
logging.debug("getting shared UIApplication obj")
app=app_cls.sharedApplication()
logging.debug("getting key window")
win=app.keyWindow
logging.debug("getting root view controller")
ctrl=win.rootViewController()
logging.debug("getting the view")
vw=ctrl.view()
logging.debug("getting the safe area insets")
logging.debug(dir(vw)) # problem 1
insets=vw.safeAreaInsets() # problem 2
However, it isn't working. dir(vw) returns a long blank string and calling safeAreaInsets() triggers an exception:
Traceback (most recent call last):
File "/Users/kent/vocabassistant-ios/YourApp/main.py", line 3, in <module>
File "/Users/kent/vocabassistant-ios/YourApp/vocab_assistant.py", line 48, in __init__
File "/Users/kent/vocabassistant-ios/YourApp/safe_area.py", line 30, in get_safe_area
File "pyobjus/pyobjus.pyx", line 488, in pyobjus.pyobjus.ObjcMethod.__call__
File "pyobjus/pyobjus_conversions.pxi", line 262, in pyobjus.pyobjus.convert_cy_ret_to_py
File "/Users/kent/Library/Developer/CoreSimulator/Devices/D196DB9F-6194-4D47-B7BD-F2DFE8670DBC/data/Containers/Bundle/Application/C9B64836-4B91-41F6-837E-B2EBFB763E2E/vocabassistant.app/lib/python3.8/site-packages/pyobjus/objc_py_types.py", line 175, in find_object
return self.make_type(obj_type, members=members)
File "/Users/kent/Library/Developer/CoreSimulator/Devices/D196DB9F-6194-4D47-B7BD-F2DFE8670DBC/data/Containers/Bundle/Application/C9B64836-4B91-41F6-837E-B2EBFB763E2E/vocabassistant.app/lib/python3.8/site-packages/pyobjus/objc_py_types.py", line 144, in make_type
field_list.append((field_name, types[_type]))
KeyError: b'd'
pakal commented
Same error here
The UIKit which defines this struct "uiedgeinsets" returned by safeAreaInsets (https://developer.apple.com/documentation/uikit/uiedgeinsets) is not in pyobjus "INCLUDE", so I assume it's already loaded as part of Foundation, and this code should work.