tags:

views:

83

answers:

2

Is it possible to add some meta-information on class, property, method in Objective-C? Something like annotations in Java or C# attributes ?

A: 

I've never used Java Annotations or C# Attributes, but from what I've read in my Googling I believe what you are looking for is Objective-C Associated Objects

http://developer.apple.com/mac/library/DOCUMENTATION/Cocoa/Conceptual/ObjectiveC/Articles/ocAssociativeReferences.html i.e.

objc_setAssociatedObject(array, &overviewKey, nil, OBJC_ASSOCIATION_ASSIGN);

Andy Mataushack has already created an Objective-C wrapper for this

http://github.com/andymatuschak/NSObject-AssociatedObjects

Colin Wheeler
I need an ability to attach some additional information to the class methods and properties, not to add additional properties(association) to the existing class. Any way thanks for fast reply ;-)
+1  A: 

Keep in mind that "associative references" only operate at runtime. This question appears to be about attaching persistent metadata to classes/properties/methods. There is no support for this currently.

pcbeard
Do u have any proof link for this statement ? I just want to be sure
Feel free to look here:http://www.opensource.apple.com/source/objc4/objc4-437.1/
pcbeard