Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Based on my tests here, properties from categories will show up when using <code>class_copyPropertyList</code>. It looks as though the properties you're seeing on UIView are only <em>described</em> as properties in the public headers, not actually declared as such when building the UIKit itself. Probably they adopted the property syntax to make the creation of the public headers a little quicker.</p> <p>For reference, here's my test project:</p> <pre><code>#import &lt;Foundation/Foundation.h&gt; #import &lt;objc/runtime.h&gt; @interface TestClass : NSObject { NSString * str1; NSString * str2; } @property (nonatomic, copy) NSString * str1; @end @interface TestClass (TestCategory) @property (nonatomic, copy) NSString * str2; @end @implementation TestClass @synthesize str1; @end @implementation TestClass (TestCategory) // have to actually *implement* these functions, can't use @synthesize for category-based properties - (NSString *) str2 { return ( str2 ); } - (void) setStr2: (NSString *) newStr { [str2 release]; str2 = [newStr copy]; } @end int main (int argc, const char * argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; unsigned int outCount, i; objc_property_t *properties = class_copyPropertyList([TestClass class], &amp;outCount); for (i = 0; i &lt; outCount; i++) { objc_property_t property = properties[i]; fprintf(stdout, "%s %s\n", property_getName(property), property_getAttributes(property)); } [pool drain]; return 0; } </code></pre> <p>And here's the output:</p> <pre><code>str2 T@"NSString",C str1 T@"NSString",C,Vstr1 </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload