-4
stringWithNums=[teststrrr removeNumbersFromString:stringWithNums];

I used category method :removeNumbersFromString this is declared in my category. same way u used this method in my subclass. what is difference between both declaration subclass and category.

Avt
  • 16,927
  • 4
  • 52
  • 72
annu
  • 137
  • 4
  • 12
  • 1
    What is your exact question? – Volker Mar 27 '14 at 07:07
  • 2
    possible duplicate of [What is the difference between inheritance and Categories in Objective-C](http://stackoverflow.com/questions/522341/what-is-the-difference-between-inheritance-and-categories-in-objective-c) – Avt Mar 27 '14 at 07:11
  • @ keyur bhalodiya What you not understood for this question. – annu Mar 31 '15 at 12:38

2 Answers2

1

There is no difference between these two. But as you know in category you cannot declare the ivar. But in subclass you can declare the ivar as well. If you want to implement and use only the methods declare in category and if not create subclass and use.

Hussain Shabbir
  • 14,801
  • 5
  • 40
  • 56
1

NSString is kind of class cluster, So I don't suggest to SubClass NSString. And If you only want to expand class function, category is better, like removeNumbersFromString. If you want to add some property, then subclass should be a good choice.

simalone
  • 2,768
  • 1
  • 15
  • 20