why isn't idMyCellDelegate an id?

2013-10-04 Thread Matt Neuburg
Here's a familiar pattern, a .h file defining a protocol and a delegate that must adopt it: @protocol MyCellDelegate; @interface MyCell : UITableViewCell @property (nonatomic, weak) idMyCellDelegate celldelegate; @end @protocol MyCellDelegate @end Here's the mystery. In the corresponding .m

Re: why isn't idMyCellDelegate an id?

2013-10-04 Thread David Duncan
On Oct 4, 2013, at 9:59 AM, Matt Neuburg m...@tidbits.com wrote: Or, (2) inherit NSObject protocol back in the protocol definition: @protocol MyCellDelegateNSObject @end You should do this. But why is either of those necessary? Surely an idMyCellDelegate is, by definition, an id

Re: why isn't idMyCellDelegate an id?

2013-10-04 Thread Kyle Sluder
On Oct 4, 2013, at 9:59 AM, Matt Neuburg m...@tidbits.com wrote: But why is either of those necessary? Surely an idMyCellDelegate is, by definition, an id Nope. A couple years back the type of idSomeProtocol was changed to only respond to the methods in the protocol. This is arguably much

Re: why isn't idMyCellDelegate an id?

2013-10-04 Thread Sean McBride
On Fri, 4 Oct 2013 09:59:53 -0700, Matt Neuburg said: -(BOOL)test { return [self.celldelegate respond sToSelector:@selector(foo:)]; // ...wait for it... } Compile error! No known instance method for selector 'respondsToSelector:'. WTF??? Here are two ways of fixing the problem. (1) Cast to

Re: why isn't idMyCellDelegate an id?

2013-10-04 Thread Jens Alfke
On Oct 4, 2013, at 9:59 AM, Matt Neuburg m...@tidbits.com wrote: But why is either of those necessary? Surely an idMyCellDelegate is, by definition, an id - which inherits from NSObject ‘id’ is not a type that inherits from NSObject. ‘id’ is explicitly untyped. ‘idMyCellDelegate’ is _not_

Re: why isn't idMyCellDelegate an id?

2013-10-04 Thread Tom Davie
On 4 Oct 2013, at 10:53, Jens Alfke j...@mooseyard.com wrote: On Oct 4, 2013, at 9:59 AM, Matt Neuburg m...@tidbits.com wrote: But why is either of those necessary? Surely an idMyCellDelegate is, by definition, an id - which inherits from NSObject ‘id’ is not a type that inherits from

Re: why isn't idMyCellDelegate an id?

2013-10-04 Thread Greg Parker
On Oct 4, 2013, at 9:59 AM, Matt Neuburg m...@tidbits.com wrote: Surely an idMyCellDelegate is, by definition, an id It is not. There is no id-style type system leniency in `idSomeProtocol`. That type must conform to the protocol and respond to its methods, and nothing more. Unlike `id` it

Re: why isn't idMyCellDelegate an id?

2013-10-04 Thread Marcel Weiher
On Oct 4, 2013, at 20:30 , Tom Davie tom.da...@gmail.com wrote: Right, really the confusion stems from the fact that objective-c has a strange behaviour when dealing with the type “id”. Actually, “id” is not “strange” at all. It just uses the very simple Smalltalk semantics: an object

Re: why isn't idMyCellDelegate an id?

2013-10-04 Thread Jens Alfke
On Oct 4, 2013, at 11:30 AM, Tom Davie tom.da...@gmail.com wrote: The more mathematically correct thing to do (and what it does for all other types) is “I don’t know what it is, so I can’t ‘prove’* anything at all about whether this is correct, therefore it’s not correct. Puny human, you

Re: why isn't idMyCellDelegate an id?

2013-10-04 Thread Matt Neuburg
On Oct 4, 2013, at 12:50 PM, Greg Parker gpar...@apple.com wrote: In practice you'll usually want to use NSObjectSomeProtocol* Well *there* is a solution I would never have thought of in a million years. I'm a bit surprised that so many built-in delegate properties in iOS (like, all of them,