> In this case you have found that the implementation of +[_NSObjectAnimator 
> resolveInstanceMethod:] crashes. 

IMHO, this is a nasty little bug… and a simple test case should be added to the 
frameworks to check that basic runtime functionality works on all classes - 
private or publicly declared. Even if nothing else is guaranteed, if a thing 
says it’s a class, then it really kinda’ should act like one.

> In general it is not safe to look up arbitrary classes and then send messages 
> to them.

True. However, he called a C runtime function… it happens that that function 
invokes the forwarding mechanism, but it’s still a basic runtime C function, 
below the level of the NSObject abstractions… so it really *should* work...

> Checking for conformance (using the C function, not the NSObject method) to a 
> protocol you defined and then only sending messages from that protocol is the 
> safest way to go.

I would (and in my own code, do) combine that with the suggestions to 
interrogate the bundle being loaded for classes to be examined, as well as do 
registration of classes in +load… I also post some notifications of my own at 
various key points in my app startup cycle that various interested classes can 
hook to.

> On Dec 15, 2014, at 3:36 PM, Maxthon Chan <m...@maxchan.info> wrote:
> 
> I ended up written my own runtime-level equivalent of +[NSObject 
> isSubclassOfClass:] using only class_getSuperclass and object_getClass. This 
> class scanning code, currently used for plugin scanning, will also be used in 
> jailbreak detecting, defeating Cydia Substrate-based iAP crackers.

You need to be very careful of how you implement that so that a future OS 
update doesn’t break your app…


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to