0

I already failed this interview but hopefully I could learn my mistakes from you guys. the question went like this.

which of the following can be achieved with 'category' and 'extension'?

1. add polymorphism to any existing classes in a platform SDK, e.g. NSString
2. add addition instance variables to existing classes in a platform SKD, e.g.NSString
3. use as a type for declaring variables
4. add additional methods to existing classes in a platform SDK, e.g.NSString

In my understanding,

category => add more functionality (new method, not property) to class without inheritance, doesn't own the class

extension => deals with property, owns class

so then intersection of category and extension should be number 3? Did I get it right? someone please shine the light on this.

aryum jeon
  • 21
  • 3
  • 2
    Looks like Apple has all the answers: https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/CustomizingExistingClasses/CustomizingExistingClasses.html – Jan Christoph Terasa Jul 30 '20 at 05:38
  • 1
    1,4 and partly 2 because it's possible. https://stackoverflow.com/questions/62953202/extend-class-in-objective-c-with-variable-based-property/62953444#62953444 in other words !3 because thats out of question. this is what classes are for. if you go along with the idea that an object of a class has a type – Ol Sen Jul 30 '20 at 05:42
  • how long was the "test" ? – Ol Sen Jul 30 '20 at 05:45
  • thank you for your references! will check it out now. – aryum jeon Jul 30 '20 at 05:47
  • 1 hour on system design presentation. 30 ~ 45 mins on these questions. and they gave me 2 hours to finish building some app on the spot. – aryum jeon Jul 30 '20 at 05:48

0 Answers0