iOS Categories

  • jonfriskics
  • 3167 views
Hall-pass

Oops, a subscription is required to view this video. You can enroll now to watch, or try out all that Code School has to offer with a free two-day Hall Pass.

Comments

Stephen said

Would categories be used more or less for 'cleaning up' your code? I feel that helper methods can be easily defined in the file of the view controller/class/etc. you're working in.

Faculty

Jon Friskics said

Joe - not a stupid question at all! You can define either class or instance methods. In this example I wanted examples of each, and since I started by talking about instance methods on NSArray, I used class methods in the UITextField examples.

Joe Kueser said

May be a stupid question, but is there a reason these should be class methods rather than instance methods? It seems that "if ([self.emailField hasValidEmail])" would be more readable than "if([UITextField fieldContainsValidEmailAddress:self.emailField])" Is that possible with categories, or would something like that require a subclass?

Gregory Zentkovich said

Thanks Jon for a great video! You did a great job of explaining iOS Categories and making it easy to understand...

nmr5316 said

make you make something on Protocols

Cezar said

excellent!

pjones said

More Please!

Rizwan Javaid said

Thanks for your clear explanation :)

Nils Diestler said

Thanks, this informations will be very useful

thangnq said

thanks :)

thehappycoder said

Is objective-c compiler able to detect method name collision and issue a warning?

About

Categories are a powerful Objective-C language feature that allow you to add methods to classes without subclassing - even methods that are part of frameworks like UIKit and Foundation. In this screencast, you'll learn how to create and implement methods by adding categories to a project.

Subscribe