0

This works fine
return [[DJLocalizationSystem shared] localizedStringForKey:(key) value: @"" table: nil bundle:bundle];
However, this does not work
return objc_msgSend([DJLocalizationSystem shared], @selector(localizedStringForKey:value:table:bundle:),(key),@"",nil,bundle);
And the method returns a string value.
enter image description here

EXC_BAD_ACCESS, code=1, address=0x8
There is a similiar question stackoverflow, but I think none of answers is correct. It has nothing to do with 0x8.

Community
  • 1
  • 1
Andy Darwin
  • 478
  • 5
  • 19
  • Andy consider this http://stackoverflow.com/a/2573949/753878, especially the part about casting, since typesafety and direct calling of objc_msgSend is far away from each other, there can be various issues with the code you provide. Aside from this different calling conventions (defined in ABI) can be different for different data types so I'd suggest not to mess with this as much as it's possible. – dymv May 12 '17 at 13:56

1 Answers1

0

objc_msgSend works fine in 32 bit iPhone and simulator, but in a 64 iPhone, you have to point out the type. So my code is
NSString *(*action)(id, SEL, NSString *, NSString *, NSString *, NSBundle *) = (NSString * (*) (id, SEL, NSString *, NSString *, NSString *, NSBundle *) ) objc_msgSend; action(system, @selector(localizedStringForKey:value:table:bundle:), (key), @"", nil, [NSBundle bundleForActionCamera]);

Andy Darwin
  • 478
  • 5
  • 19