Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyError at field_list.append() #70

Open
freemant2000 opened this issue Oct 14, 2020 · 1 comment
Open

KeyError at field_list.append() #70

freemant2000 opened this issue Oct 14, 2020 · 1 comment

Comments

@freemant2000
Copy link

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
Copy link

pakal commented Oct 13, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants