objective c - How to use protocols with categories for NSMutableArray -


i don't think i've found example quite own on site though i'm sure pops time, , finished chapter on subject in my book.

i'm not looking complicated, want add functionality nsmutablearray objects of type because don't want subclass nsmutablearray because seems difficult, may change mind that.

i want category offers nsmutablearrays conform ndvector protocol ability things calculate norm, rotate axis, etc.

i've tried couple things, , i'm thinking should this:

  • make protocol: @protocol ndvector <nsmutablearray> , declare methods there
  • create category @interface nsmutablearray (ndvector) that... declares methods?
  • implement methods in category's implementation @implementation nsmutablearray (ndvector)
  • and finally, somehow instantiate nsmutablearray<ndvector> (i'm coming java), object nsmutablearray<ndvector> vec = [[nsmutablearray alloc] init]

how should doing this? please don't send link, provide explanation parallels methodology, correct steps involved.

none of current approaches best way. suggest create vector class happens use mutable array in own implementation.

you have init method in vector class takes array.


Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -