Skip to content

KeyError at field_list.append() #70

@freemant2000

Description

@freemant2000

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'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions