Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6205687
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:19:07+00:00 2026-05-24T05:19:07+00:00

I try to proxy existing Python class to Objective-C. I started from simple sample

  • 0

I try to proxy existing Python class to Objective-C. I started from simple sample of Python class:

Test.py


class Test:
    def __init__(self):
        self.text = ""

    def addText(self, _text):
        self.text = self.text + _text

    def addSomeText(self):
        self.addText("SomeText")

Then I wrote Objective-C class for it.

ITest.h


#import <Cocoa/Cocoa.h>


@interface ITest : NSObject

- (void) addText: (NSString *)text;
- (void) addSomeText;

+ newTest;

@property (nonatomic, assign, getter = _text) NSString *text;

@end

ITest.m


#import "ITest.h"

#define ABSTRACT { return nil; }
#define ABSTRACT_VOID { }


@implementation ITest
@dynamic text;

- (void) addText: (NSString *)text ABSTRACT_VOID;
- (void) addSomeText ABSTRACT_VOID;

+ newTest {
    return [[NSClassFromString(@"TestProxy") new] autorelease];
}

@end

My proxy class (following some articles about PyObjC I subclassing Objective-C class and subclassing original class to access its instance variables):

TestProxy.py


import Foundation
import objc

from Test import Test

ITest = objc.lookUpClass("ITest")

class TestProxy (ITest, Test):
    # getters/setters
    def setText_(self, _text):
        self.text = _text

    def _text(self):
        return self.text

    # methods
    def addText_(self, text):
        Test.addText(self, text)

    def addSomeText(self):
        Test.addSomeText(self)

Now, if I do

ITest *test = [ITest newTest];

I always get nil with no warnings or errors in the debug console.

If I remove all imports and references to original Test class, I’ll get working object. I noticed, that nil will be returned exactly as soon as I add from Test import Test.

I think this happens because PyObjC trying to bridge the Test class and fails because its methods do not conform bridge naming rules.

Is there a way to say PyObjC not to do so? Or, maybe, all stuff I did is wrong and there is a better way to translate existing Python stuff to Objective-C?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T05:19:08+00:00Added an answer on May 24, 2026 at 5:19 am

    I just want to make sure that you wrote newText method without return type intentionally..
    objective-c methods have its return type most likely, and if you don’t want to a specific type to be return use keyword “id”.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I can invoke and test web service but when i try to generate proxy
I can invoke and test web service but when i try to generate proxy
I try to test a site with Jmeter and I used its HTTP Proxy
I try to call methods from klipper bus with python. But I could not
Take this code into consideration: Proxy p = new Proxy(Type.SOCKS, new InetSocketAddress(proxyURL, port)); try
Try as I might I cannot get my head around what the IteratorIterator class
I'm building a contract-first SOAP client. When I try to generate the proxy classes
I'm trying to add authenticating proxy support to an existing script, as it is
Like the title says, my code basically does this: set proxy, test proxy, do
I'm trying to generate a proxy class with WCF which, when serialized, converts and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.