How to detect a property return type in Objective-C

后端 未结 6 1751
南旧
南旧 2020-12-05 11:10

I have an object in objective-c at runtime, from which I only know the KVC key and I need to detect the return value type (e.g. I need to know if its an NSArray or NSMutable

6条回答
  •  南笙
    南笙 (楼主)
    2020-12-05 11:38

    If you know that the property is defined :

            id vfk = [object valueForKey:propertyName];
            Class vfkClass = vfk.class;
    

    And compare with isKindOfClass, isSubClass, etc.

提交回复
热议问题