title: Custom property attributes in Objective-c
body: <p>Can custom property attributes be created in Objective-C just like in VB.NET? For example, in VB.NET you can create the "Browsable" attribute and read it at runtime to determine whether you should display a property or not.</p>
  
  <pre><code>Public Class Employee
      &lt;Browsable(True)&gt; _
      Public Property Property1() As String
          Get
  
          End Get
          Set(ByVal Value As String)
  
          End Set
      End Property
  
      &lt;Browsable(False)&gt; _
      Public Property Property2() As String
          Get
  
          End Get
          Set(ByVal Value As String)
  
          End Set
      End Property
  End Class
  </code></pre>
  
  <p>I would like to do the same in Objective-C, even if it is a fixed attribute that can only be set at compile time and cannot be changed at all. </p>
  
  <p>What I'm trying to do is to add an attribute to properties of my class to determine whether the properties should be serialized or not. </p>
  
  <p>I know the standard Objective-C attributes (readonly, nonatomic, etc.), but those don't help me... unless you have a creative way of using them. I also looked into using C attributes with the <code>__attribute__(("Insert attribute here"))</code> keyword, but C has specific attributes that serve specific purposes, and I'm not even sure you can read them at runtime. If I missed one that can help me, let me know.</p>
  
  <p>I tried using <code>typdef</code>. For example:</p>
  
  <pre><code>typdef int serializableInt;
  serializableInt myInt;
  </code></pre>
  
  <p>and use the <code>property_getAttributes()</code> Objective-C runtime function, but all it tells me is that myInt is an int. I guess typedef is pretty much like a macro in this case... unless I can create a variable of type serializableInt at runtime. Anyhow, here's <a href="http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/ObjCRuntimeGuide/Articles/ocrtPropertyIntrospection.html#//apple_ref/doc/uid/TP40008048-CH101" rel="noreferrer">Apple's documentation</a> on the values you get from <code>property_getAttributes()</code>. </p>
  
  <p>The other requirement is that this attribute has to work with NSObject sub-classes as well as primitive data types. I thought about the idea of adding to the class a black lists or white lists as an ivar that would tell me which properties to skip or serialize, which is basically the same idea. I'm just trying to move that black/white list to attributes so it's easy to understand when you see the header file of a class, it's consistent across any class I create and it's less error prone.</p>
  
  <p>Also, this is something to consider. I don't really need the attribue to have a value (TRUE or FALSE; 1, 2, 3; or whatever) because the attribute itself is the value. If the attribute exists, then serialize; otherwise, skip.</p>
  
  <p>Any help is appreciated. If you know for sure that this is not possible on Objective-C, then let me know. Thanks.</p>