objc-message-send

How to pass an array to an objc method that expects var args (eg …')

偶尔善良 提交于 2020-01-04 01:29:14
问题 I have a method in a library that looks like so: - (id)initWithSomeObjects:(NSString *)something, ... NS_REQUIRES_NIL_TERMINATION; I'd really like to call it with an array instead of var args, because the number of objects i'd like to pass in is changeable. Is there some way, using performSelector or NSInvocation or objc_msgSend or whatever, that i can call the var args method, with the arguments coming from an array? 回答1: There is no easy way to do this, because how arguments are passed goes

Why is objc_msgSend causing an EXC_BAD_ACCESS?

瘦欲@ 提交于 2019-12-10 13:28:35
问题 I'm making a class, that given an object target, a selector to watch for, and a displayTitle will output a string in this format: @"displayTitle: object.selector" . It then registers itself through KVO so that anytime the value of object.selector changes, it can notify a view controller to update the view. I am using this as an abstract and reusable way to show a description of various properties of an object to a user. When I try to get the value of object.selector , I can't do [object