Comments (4)
Yes. When you use the @objc_method
decorator, that registers the method as an Objective-C entry point; it can be invoked from the Python side, or from the objective C side. This is used when you start writing handlers (e.g., button press callbacks) - you write a handler with an onPress:
selector in python, and register the instance of the (Python side) handler object to the button API. when the button is pressed, it invokes onPress_()
on the Python side.
The only issue then is how to pass the created object back to the objective-C side. This will usually be done by setting a property, or invoking a "setHandler:" style method, but that's up to exactly what you're implementing.
from rubicon-objc.
I am still having trouble getting objective c to see the methods I have marked with @objc_method in python. I wanted to check if I have installed rubicon correctly. I am using ios and could not figure out how to do a direct install, so I ran "setup install" on my host machine and installed the files to a temp directory. I then copied the files to my app_packages directory (I am using your cookie cutter download). I then copied the objective c test files( i.e. Example.m) into my app.
I can get some features to work I can run the python-side examples you provided in the ReadMe file. I can also create objects in python using objective c class descriptions ( i.e. the Example class files in your test library). The problem comes when I try to access anything that was created in python on the objective c side. If you had an example of how to call an object crated in python on the objective c side that would be very helpful. Thanks
from rubicon-objc.
@Siege097 The key point is that you can't just create the instance and have it "appear" in the objective C side. It needs to be passed in as an argument, or set as an attribute somewhere in the system. So - it's not enough to just create the instance - you have to "tell" the Objective C part which
You can see an example of this in the Rubicon test suite. In that example, and Handler
object is instantiated; it's passed to an instance of the Example
class as the callback
attribute. In this case, the instance of example is being created on the Python side, but could have been created objective-C side and accessed via an attribute or method. Then, when testPeek_
and testPoke_
are invoked, the callback (defined Python side) is invoked.
from rubicon-objc.
Ok great, Thanks for your help
from rubicon-objc.
Related Issues (20)
- Enforce `restype` and `argtypes` for `send_super` HOT 2
- I am passing the correct number of arguments, however stilling hitting "takes 7 arguments, but got 5 arguments" HOT 5
- Improve repr() calls for NSPoint/NSRect types
- Calling performSelector for a @objc_method created by rubicon from Objective C crashes in Python 3.9 HOT 3
- Blocks not fully working on M1 hardware HOT 5
- "ObjC Class 'b'WrappedPyObject'' couldn't be found." when running on iOS device HOT 7
- iOS event loop blocks when thread waits on socket.
- x86_64 machine architecture not identified correctly on iOS simulator
- Attribute intermittently returns the wrong object HOT 5
- Segmentation fault when exiting multi-threaded program
- Race condition when instantiating ObjCInstance objects
- Race condition when populating the ObjCClass method/attribute cache
- Update CI configuration to test release artefacts
- Improve correspondence between ObjectiveC objects and Python wrappers HOT 17
- New caching logic may inadvertently release objects that are still needed HOT 5
- ctypes.ArgumentError message is split into individual characters
- Warning about deprecated `pkg_resources` API
- Incompatibility with `from __future__ import annotations` HOT 1
- Incompatibility with Python 3.12.0b1 HOT 4
- Scroll blocks eventloop for ios HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rubicon-objc.