omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    objc_util access `super`

    Pythonista
    3
    3
    2152
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • lukaskollmer
      lukaskollmer last edited by

      Hi,

      I'm creating a subclass of UITextView using create_new_class.

      This subclass implements a couple of methods specific to UITextView.

      How can I access/call super in these methods?

      1 Reply Last reply Reply Quote 0
      • dgelessus
        dgelessus last edited by

        This looks like something that objc_util doesn't natively support. The relevant declarations from Apple's Objective-C Runtime Reference are:

        struct objc_super {
            id receiver; // Object to which to send the message
            Class class; // Superclass whose implementation should be used
        };
        
        id objc_msgSendSuper(struct objc_super *super, SEL op, ...);
        void objc_msgSendSuper_stret(struct objc_super *super, SEL op, ...);
        
        1 Reply Last reply Reply Quote 0
        • JonB
          JonB last edited by JonB

          you should be able to copy the from ObjCInstanceMethod, and change the objc_class line:

          class ObjCInstanceMethodSuperclass (object):
          	'''Wrapper for an Objective-C instance method. ObjCInstance generates these objects automatically when accessing an attribute, you typically don't need to use this class directly.'''
          	def __init__(self, obj, method_name, allow_property=True):
          		self.obj = obj
          		objc_class = obj.superclass() #modified!!
                          ......
          

          then create one manually.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post
          Powered by NodeBB Forums | Contributors