-4

Good day!=) I have "super" class and category for it) For super class i defined a protocol delegate property but i can't call it in category in method. Is it possible anyway? Thanks everybody for answering=)

Alex Kraev
  • 199
  • 1
  • 12
  • 3
    Can you provide a code example of what you're trying to do? – James Frost Jan 22 '14 at 20:32
  • 1
    Definitely need to see your code. You can't define a 'method' as a 'property' so your question title doesn't make sense. – Wain Jan 22 '14 at 20:42
  • 1
    I don't get anything here im afraid. please try to reformulate, provide more details & code as well – Daij-Djan Jan 22 '14 at 20:48
  • Yes, my question is not right. It was simple mistake in my code and therefore couldn't subscribe for event of delegation( All in all Duncan is right=) – Alex Kraev Jan 23 '14 at 22:50

1 Answers1

1

Your terms are all confused. A category is not a superclass or a subclass. A category adds methods to an existing class.

A method is not a property, so "defining a delegate method property" does not make sense.

You can't add new instance variables to an object in a category, so you can't add normal properties at all. You can create properties with custom getters/setters that don't use instance variables, or that use existing instance variables (for example if you had a "Person" class that had a "firstName" property and a "lastName" property you could create a new read-only property "fullName" that concatenated the first and last name and returned the result.)

Duncan C
  • 128,072
  • 22
  • 173
  • 272
  • I recommend to look at [this](http://stackoverflow.com/a/14899909/3086454) answer for good example. – d12frosted Jan 22 '14 at 21:34
  • @RottenBrain, Given that the OP can't describe what he's trying to do in coherent sentences I think associative storage is a little beyond his current abilities. Cool technique, but not for newbies. – Duncan C Jan 22 '14 at 21:39
  • Maybe you're right. But this is really great technique for implementing "property" in category. – d12frosted Jan 22 '14 at 21:48
  • Yes, my question is not right. It was simple mistake in my code and therefore couldn't subscribe for event of delegation( All in all Duncan is right=) – Alex Kraev Jan 23 '14 at 22:47