Re: Switching methods in private classes in Apple frameworks
Re: Switching methods in private classes in Apple frameworks
- Subject: Re: Switching methods in private classes in Apple frameworks
- From: Greg Parker <email@hidden>
- Date: Thu, 11 Mar 2010 16:31:27 -0800
On Mar 11, 2010, at 4:24 PM, Gideon King wrote:
> (following on from the thread "How to debug this error on closing a document?", but it's really moved on to a new topic at this point)
>
> I was not aware that poseAsClass is not available in 64 bit applications. I looked at the Apple example of exchanging a method in NSWindow, and it looked easy enough, so I tried the method exchanging by using class-dump to generate the header for NSConcreteNotification, and implemented the switch, but it gives a linker error:
>
> "_OBJC_CLASS_$_NSConcreteNotification", referenced from:
> l_OBJC_$_CATEGORY_NSConcreteNotification_$_MethodReplacement in MyConcreteNotification.o
> __objc_classrefs__DATA@0 in MyConcreteNotification.o
> ld: symbol(s) not found
> collect2: ld returned 1 exit status
>
> So it must be in the foundation binary, but the linker doesn't pick it up. Is there a way around this?
On iPhone and 64-bit Mac, the linker enforces internal classes more strictly. NSConcreteNotification is private, so you can't link to it or subclass it. You can still get the class via runtime introspection like NSClassFromString(), which for debugging purposes ought to be good enough.
--
Greg Parker email@hidden Runtime Wrangler
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden