I've been using objc_msgsend, but I didn't notice Apple's documentation, so suddenly objc_msgsend crash. There is no problem with the previous 32 bits, and then the exc_bad_access problem occurs after converting to 64 bits. Of course Apple re-documentation ([64-bit Transition Guide for Cocoa Touch] (https://developer.apple.com/library/prerelease/ios/ Documentation/general/conceptual/cocoatouch64bitguide/convertingyourappto64-bit/convertingyourappto64-bit.html #//apple_ref/doc/uid/tp40013501-ch3-sw26)) also mentions: Dispatch objective-c Messages Using the Method Function ' s Prototypean Exception to the casting rule described above was when you were calling the Objc_msgsend function or any other similar funct Ions in the OBJECTIVE-C runtime that send messages. Although the prototype for the message functions have a variadic form, the method function that's called by the objective- C runtime does not share the same prototype. The OBJECTIVE-C runtime directly dispatches to the function that implements the method, so the calling conventions is MIS Matched, as described previously. Therefore must cast the Objc_msgsend function to a prototype thaT matches the method function being called. Listing 2-14 shows the proper form for dispatching a message to an object using the low-level message functions. In this example, the Dosomething:method takes a single parameter and does not has a variadic form. It casts the Objc_msgsend function using the prototype of the method function. Note that the A method function always takes an ID variable and a selector as its first and a parameters. After the Objc_msgsend function was cast to a function pointer, the call is dispatched through that same function pointer you must The prototype must be defined before it can be used, so that the crash ID fun (int x,id y,...) does not occur; ID (*action) (int,id) = (ID (*) (Int,id)) fun;action (1,@ "s"); if no return value ID is changed to void the original we wrote: Objc_msgsend (self, @selector ( DoSomething:), 0); According to Apple's specification:-(int) dosomething: (int) x {...} -(void) dosomethingelse {int (*action) (ID, sel, int) = (int (*) (ID, sel, int)) Objc_msgsend; Action (self, @selector (dosomething:), 0);} Final simplification after 64-bit invocation: ((void (*) (ID, sel,int)) objc_msgsend) (Self, @selector (dosomething:), 0);
Original: Http://blog.iloss.me/post/kai-fa/2014-12-09-objc_msgsend?action=show_raw
Implicitly declaring library function ' objc_msgsend ' with type ' (Id,sel,...) ' Warning