Re: respondsToSelector warning: may not respond

2010-11-27 Thread Mikkel Eide Eriksen
Thanks all,

I ended up changing around my object hierarchy and casting to a superclass that 
has ordinals.

Mikkel

On Nov 26, 2010, at 10:38 PM, Julien Jalon wrote:

 Z) ignore the warning
 
 On Fri, Nov 26, 2010 at 9:44 PM, Ken Thomases k...@codeweavers.com wrote:
 On Nov 26, 2010, at 12:27 PM, Mike Abdullah wrote:
 
  C) Typecast the object to a class that is known to implement -setOrdinal:
 
 D) Typecast the object to id.
 
 Regards,
 Ken
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/jjalon%40gmail.com
 
 This email sent to jja...@gmail.com
 



smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: respondsToSelector warning: may not respond

2010-11-27 Thread David Duncan
On Nov 26, 2010, at 6:22 PM, Dave Zwerdling wrote:

 You can implement other methods and do a single cast to NSObject 
 nameOfProtocol* (or idnameOfProtocol if you don't need the NSObject 
 methods)


It is often impossible to get away from needing at least some of NSObject's 
functionality, but fortunately you can declare that your protocol inherits from 
another, and there is also an NSObject protocol that defines the core 
functionality of the class, so you can do this when you declare your protocol 
and never need to worry about NSObjectsomeProtocol

@protocol SomeProtocol : NSObject
// stuff
@end
--
David Duncan

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: respondsToSelector warning: may not respond

2010-11-27 Thread Andy Lee
On Nov 27, 2010, at 12:35 PM, David Duncan david.dun...@apple.com wrote:

  fortunately you can declare that your protocol inherits from another, and 
 there is also an NSObject protocol that defines the core functionality of the 
 class, so you can do this when you declare your protocol and never need to 
 worry about NSObjectsomeProtocol
 
 @protocol SomeProtocol : NSObject
 // stuff

AFAIK protocols don't inherit from each other but rather conform to each other, 
meaning the above should be

@protocol SomeProtocol NSObject

But maybe I'm just unaware of new syntax in the latest compiler?

--Andy

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: respondsToSelector warning: may not respond

2010-11-27 Thread David Duncan
On Nov 27, 2010, at 9:46 AM, Andy Lee wrote:

 AFAIK protocols don't inherit from each other but rather conform to each 
 other, meaning the above should be
 
 @protocol SomeProtocol NSObject
 
 But maybe I'm just unaware of new syntax in the latest compiler?


No, your probably right. Dangers of typing code into Mail instead of a compiler 
:).
--
David Duncan

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: respondsToSelector warning: may not respond

2010-11-27 Thread Stephen J. Butler
Or I believe you can also do id NSObject, MyProtocol  if you need
something that conforms to both. Unless you actually need something
that is only implemented in the NSObject class and not defined in the
protocol.

On Sat, Nov 27, 2010 at 11:35 AM, David Duncan david.dun...@apple.com wrote:
 On Nov 26, 2010, at 6:22 PM, Dave Zwerdling wrote:

 You can implement other methods and do a single cast to NSObject 
 nameOfProtocol* (or idnameOfProtocol if you don't need the NSObject 
 methods)


 It is often impossible to get away from needing at least some of NSObject's 
 functionality, but fortunately you can declare that your protocol inherits 
 from another, and there is also an NSObject protocol that defines the core 
 functionality of the class, so you can do this when you declare your protocol 
 and never need to worry about NSObjectsomeProtocol

 @protocol SomeProtocol : NSObject
 // stuff
 @end
 --
 David Duncan

 ___

 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com

 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/stephen.butler%40gmail.com

 This email sent to stephen.but...@gmail.com

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


respondsToSelector warning: may not respond

2010-11-26 Thread Mikkel Eide Eriksen
Hi all,

I have the following bit in my code:

if ([obj respondsToSelector:@selector(setOrdinal:)]) {
[obj setOrdinal:value];
}

XCode gives a warning that obj may not respond to setOrdinal: which won't be a 
problem unless something is really screwy. But how do I get rid of the warning? 
Or do I just live with it?

Regards,
Mikkel

smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: respondsToSelector warning: may not respond

2010-11-26 Thread Mikkel Eide Eriksen
I should have mentioned that it is declared, but obj can be one of many classes 
only some of which have setOrdinal:

On Nov 26, 2010, at 6:46 PM, banane wrote:

 declare the method in your header file. -(void)setOrdinal;
 
 On Fri, Nov 26, 2010 at 9:08 AM, Mikkel Eide Eriksen 
 mikkel.erik...@gmail.com wrote:
 Hi all,
 
 I have the following bit in my code:
 
 if ([obj respondsToSelector:@selector(setOrdinal:)]) {
[obj setOrdinal:value];
 }
 
 XCode gives a warning that obj may not respond to setOrdinal: which won't be 
 a problem unless something is really screwy. But how do I get rid of the 
 warning? Or do I just live with it?
 
 Regards,
 Mikkel
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/banane%40gmail.com
 
 This email sent to ban...@gmail.com
 



smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: respondsToSelector warning: may not respond

2010-11-26 Thread Mike Abdullah
You have many options, in rough order of cleanness:

A) Declare a protocol that your objects conform to. Make -setOrdinal: @optional

B) Do [object performSelector:@selector(setOrdinal:) withObject:value] or use 
-setValue:forKey:

C) Typecast the object to a class that is known to implement -setOrdinal:

On 26 Nov 2010, at 17:47, Mikkel Eide Eriksen wrote:

 I should have mentioned that it is declared, but obj can be one of many 
 classes only some of which have setOrdinal:
 
 On Nov 26, 2010, at 6:46 PM, banane wrote:
 
 declare the method in your header file. -(void)setOrdinal;
 
 On Fri, Nov 26, 2010 at 9:08 AM, Mikkel Eide Eriksen 
 mikkel.erik...@gmail.com wrote:
 Hi all,
 
 I have the following bit in my code:
 
 if ([obj respondsToSelector:@selector(setOrdinal:)]) {
   [obj setOrdinal:value];
 }
 
 XCode gives a warning that obj may not respond to setOrdinal: which won't be 
 a problem unless something is really screwy. But how do I get rid of the 
 warning? Or do I just live with it?
 
 Regards,
 Mikkel
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/banane%40gmail.com
 
 This email sent to ban...@gmail.com
 
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/cocoadev%40mikeabdullah.net
 
 This email sent to cocoa...@mikeabdullah.net

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: respondsToSelector warning: may not respond

2010-11-26 Thread Ken Thomases
On Nov 26, 2010, at 12:27 PM, Mike Abdullah wrote:

 C) Typecast the object to a class that is known to implement -setOrdinal:

D) Typecast the object to id.

Regards,
Ken

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: respondsToSelector warning: may not respond

2010-11-26 Thread Julien Jalon
Z) ignore the warning

On Fri, Nov 26, 2010 at 9:44 PM, Ken Thomases k...@codeweavers.com wrote:

 On Nov 26, 2010, at 12:27 PM, Mike Abdullah wrote:

  C) Typecast the object to a class that is known to implement -setOrdinal:

 D) Typecast the object to id.

 Regards,
 Ken

 ___

 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com

 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/jjalon%40gmail.com

 This email sent to jja...@gmail.com

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: respondsToSelector warning: may not respond

2010-11-26 Thread jonat...@mugginsoft.com

On 26 Nov 2010, at 21:38, Julien Jalon wrote:

 Z) ignore the warning
 

Z^Z) ignore that

Regards

Jonathan Mitchell

Developer
Mugginsoft LLP
http://www.mugginsoft.com

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: respondsToSelector warning: may not respond

2010-11-26 Thread Dave Zwerdling
I always take the protocol route.  You can implement other methods and do a 
single cast to NSObject nameOfProtocol* (or idnameOfProtocol if you don't 
need the NSObject methods) and then just pass around that.  All you have to 
check for in instantiation is that it passes implementsProtocol: and then 
you're set.  After that, not only do you typically have the ability to forgo 
these warnings (they won't appear) but so long as you import the protocol 
header, XCode will implement code completion for the protocol, which is nice.

I use protocols for internal classes for pull-up refactoring, too.  After 
creating and requiring the protocol in the object, if you change the 
controllers, all you have to do is change the method name in the protocol.  
XCode will throw warnings in all the places that the method should -but isn't- 
implemented.
Dave


On Nov 26, 2010, at 10:27 AM, Mike Abdullah wrote:

 You have many options, in rough order of cleanness:
 
 A) Declare a protocol that your objects conform to. Make -setOrdinal: 
 @optional
 
 B) Do [object performSelector:@selector(setOrdinal:) withObject:value] or use 
 -setValue:forKey:
 
 C) Typecast the object to a class that is known to implement -setOrdinal:
 
 On 26 Nov 2010, at 17:47, Mikkel Eide Eriksen wrote:
 
 I should have mentioned that it is declared, but obj can be one of many 
 classes only some of which have setOrdinal:
 
 On Nov 26, 2010, at 6:46 PM, banane wrote:
 
 declare the method in your header file. -(void)setOrdinal;
 
 On Fri, Nov 26, 2010 at 9:08 AM, Mikkel Eide Eriksen 
 mikkel.erik...@gmail.com wrote:
 Hi all,
 
 I have the following bit in my code:
 
 if ([obj respondsToSelector:@selector(setOrdinal:)]) {
  [obj setOrdinal:value];
 }
 
 XCode gives a warning that obj may not respond to setOrdinal: which won't 
 be a problem unless something is really screwy. But how do I get rid of the 
 warning? Or do I just live with it?
 
 Regards,
 Mikkel
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/banane%40gmail.com
 
 This email sent to ban...@gmail.com
 
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/cocoadev%40mikeabdullah.net
 
 This email sent to cocoa...@mikeabdullah.net
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/zwerdlds%40gmail.com
 
 This email sent to zwerd...@gmail.com

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com