summaryrefslogtreecommitdiff
path: root/delegate_darwin.go
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-03-30 13:21:10 -0400
committerPietro Gagliardi <[email protected]>2014-03-30 13:21:10 -0400
commit8f944c7ec6ba0efaa6dd649934bc2badaef5ab22 (patch)
treefb68e290da74f0c8f964f6fe3ed996eb49f64194 /delegate_darwin.go
parent08dfb5da2034c33b68d7247dd16925960b3b88a3 (diff)
When we created our delegate and view classes on Mac OS X, it turned out we were accidentally subclassing the metaclass (of NSObject and NSView, respectively), not the actual superclass itself. Fixed tha. This also fixed that mysterious objc_new()/[object init] not working on the delegate class problem.
Diffstat (limited to 'delegate_darwin.go')
-rw-r--r--delegate_darwin.go9
1 files changed, 5 insertions, 4 deletions
diff --git a/delegate_darwin.go b/delegate_darwin.go
index c60689d..7f14d04 100644
--- a/delegate_darwin.go
+++ b/delegate_darwin.go
@@ -64,9 +64,7 @@ func mkAppDelegate() error {
if err != nil {
return fmt.Errorf("error adding NSApplication delegate buttonClicked: method (to handle button clicks): %v", err)
}
- // TODO using objc_new() causes a segfault; find out why
- // TODO make alloc followed by init (I thought NSObject provided its own init?)
- appDelegate = objc_alloc(objc_getClass(_goAppDelegate))
+ appDelegate = objc_new(objc_getClass(_goAppDelegate))
return nil
}
@@ -111,7 +109,10 @@ func appDelegate_buttonClicked(self C.id, sel C.SEL, button C.id) {
// this actually constructs the delegate class
var (
- _NSObject_Class = C.object_getClass(_NSObject)
+ // objc_getClass() says it returns an id but it's actually a Class
+ // thanks to Psy| in irc.freenode.net/##objc
+ // don't call object_getClass() on this then, as I originally thought — that returns the /metaclass/ (which we don't want, and in fact I wasn't even aware we COULD subclass the metaclass directly like this)
+ _NSObject_Class = C.Class(unsafe.Pointer(_NSObject))
)
func makeDelegateClass(name string) (C.Class, error) {