• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Objective-C Categories

 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey,
Categories in Objective-C are used to add additional methods to existing classes without subclassing them.
Does this mean that Objective-C support some sort of Meta-programming?
Thanks.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's not what I'd typically consider meta-programming, which to me means things like macros ("programs that write programs") or meta-object protocols.

http://en.wikipedia.org/wiki/Metaprogramming
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's basically monkeypatching.

This is incredibly valuable in Objective-C, often because many of the Cocoa APIs are... not everything they could be. If you're sick of passing the same parameter to some method or having to call 3 or more methods together to perform a single unit of work, just create your own method to make things easier.

You'll likely carry your Categories like a tool belt from project to project. The more conveniences you give yourself, the better your overall productivity.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic