-
Notifications
You must be signed in to change notification settings - Fork 47
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
UninitializedDeallocWarning: NSNotification object with postNotification_ is empty and wont work #458
Comments
PyObjC maps Objective-C's method calls directly into Python. Because of this object creation is a two step process, an explicit version of Python's obj = NSObject.alloc().init() Leaving out the call to an In your particular case the call to @objc.IBAction
def helplink_(self, url):
x = Cocoa.NSNotification.alloc().init() # Or probably x = Cocoa.NSNotification.notificationWithName_object_("hi", 42)
Cocoa.NSNotificationCenter.defaultCenter().postNotification_(x) BTW. I intent to add more pythonic object creation in a future version, hopefully this year. See #275 for the basic idea. |
What do you mean by exactly making it more pythonic? Meaning allowing things ot be simplified in certain ways, super or subclassing stuff? P.S. Also, I made a discord server for people to talk and get support about this, it has a simple open-source wiki with tickets for people to add good info. https://dsc.gg/pyobjc If you think it would be helpful you can link it somewhere, or otherwise ill invite someone separately if I help them I dont know |
Sadly after I wrote the above comment, I got this error: /Users/ddd/PycharmProjects/shoutout/main.py:73: UninitializedDeallocWarning: leaking an uninitialized object of type NSConcreteNotification However with However, no notification showed up sadly |
Problem
Having trouble making a notification come up. I believe I am getting the warning because the object
x
I am making in the first place is empty as from print statements. After the failed attempt too, no print statements would show up again too.Cocoa.NSNotification.alloc().init_()
is supposed to be an empty notification called byCocoa.NSNotificationCenter.alloc().postNotification_(x)
, but it doesn't work and I get the UninitializedDeallocWarning error below:Code
Error
Here is working code for launching a NSURL string object...
I am confused on how I can solve this, I will try to figure out a way to use other ones besides
postNotification:
orinitWithName:object:userInfo:
, etc. Any help on what I am doing wrong?The text was updated successfully, but these errors were encountered: