Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save hamada147/5d6963398c0aaf3ac8d26abeb4e1e69d to your computer and use it in GitHub Desktop.
Save hamada147/5d6963398c0aaf3ac8d26abeb4e1e69d to your computer and use it in GitHub Desktop.
While creating an NSObject in Run time I faced an issue that creating only Ivar in the created class will make it only valid for the first time use which is more like a weak reference then it will deallocate automatically which would be very helpful if you are going to use it one time only but I was going to reuse created NSObject which made thi…
unsigned propertyCount = 0;
// replace BanksModel with the class name you want to find out its attributes
objc_property_t *properties = class_copyPropertyList([BanksModel class], &propertyCount);
for (int prop = 0; prop < propertyCount; prop++) {
// for all property attributes
unsigned int attributeCount = 0;
objc_property_attribute_t * attributes = property_copyAttributeList(properties[prop], &attributeCount);
for (unsigned int attr = 0; attr < attributeCount; attr++) {
NSLog(@"Attribute %d: name: %s, value: %s", attr, attributes[attr].name, attributes[attr].value);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment