Is there a way to log all the property values of an Objective-C instance

前端 未结 5 1666
庸人自扰
庸人自扰 2021-02-04 03:22

I was just wondering if there is a quick and easy way of printing out to the log all of the various values of the properties to my class for debugging purposes. Like I would lik

5条回答
  •  庸人自扰
    2021-02-04 03:51

    There are now these methods on NSObject :

    @interface NSObject (Private)
    -(id)_ivarDescription;
    -(id)_shortMethodDescription;
    -(id)_methodDescription;
    @end
    

    In swift:

    myObject.perform("_ivarDescription")
    

    Thanks to this article

提交回复
热议问题