0

I've been searching this on Google for a while and haven't been able to come up with anything.

I'm building a library, and this library would be a lot easier and more intuitive to use if I were able to add custom properties to all of Apple's pre built objects, IE. NSString, UIImage, etc.

If it's not possible to add properties, what's the next best thing?

I've seen similar things on stack overflow, but all of them are about categories for custom made objects.

Thanks in advance!

Michael King
  • 640
  • 1
  • 6
  • 18
  • It's possible to add _methods_, but not _ivars_. That's about one-half of the declared property functionality. You can declare properties in categories; they just can't be synthesized. What's the particular problem you're facing? – jscs Apr 24 '14 at 04:25

1 Answers1

1

You want associated objects. You cannot simply add properties to existing classes using a category.

http://oleb.net/blog/2011/05/faking-ivars-in-objc-categories-with-associative-references/

CrimsonChris
  • 4,651
  • 2
  • 19
  • 30