FROM : Joan Lluch (casa)
DATE : Sun Jun 08 23:04:05 2008
El 08/06/2008, a las 22:11, Kyle Sluder escribió:
> On Sun, Jun 8, 2008 at 1:37 PM, Joan Lluch (casa) <<email_removed>>
> wrote:
>> return ( item && [[item representedObject] isKindOfClass:[GroupNode
>> class]] ) ;
>
> Style note: you don't need to do this. [[item representedObject]
> isKindOfClass:[GroupNode class]] will work just fine, because messages
> to nil return zero or their logical equivalent. So if item == nil,
> then [item representedObject] == nil, which means that [[item
> representedObject] isKindOfClass:[GroupNode class]] == NO.
>
> Of course, this all works only if the GroupNode class exists. ;-)
>
> --Kyle Sluder
Yes, of course, objective-C allows you to send messages to nil but
coming from a c++ background I just am used to do check for nullity
first. On the other hand, checking an object for nil in an early stage
will in some cases give a performance improvement. Not in the above
code, obviously. :)_______________________________________________
Cocoa-dev mailing list (<email_removed>)
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/<email_removed>
This email sent to <email_removed>
DATE : Sun Jun 08 23:04:05 2008
El 08/06/2008, a las 22:11, Kyle Sluder escribió:
> On Sun, Jun 8, 2008 at 1:37 PM, Joan Lluch (casa) <<email_removed>>
> wrote:
>> return ( item && [[item representedObject] isKindOfClass:[GroupNode
>> class]] ) ;
>
> Style note: you don't need to do this. [[item representedObject]
> isKindOfClass:[GroupNode class]] will work just fine, because messages
> to nil return zero or their logical equivalent. So if item == nil,
> then [item representedObject] == nil, which means that [[item
> representedObject] isKindOfClass:[GroupNode class]] == NO.
>
> Of course, this all works only if the GroupNode class exists. ;-)
>
> --Kyle Sluder
Yes, of course, objective-C allows you to send messages to nil but
coming from a c++ background I just am used to do check for nullity
first. On the other hand, checking an object for nil in an early stage
will in some cases give a performance improvement. Not in the above
code, obviously. :)_______________________________________________
Cocoa-dev mailing list (<email_removed>)
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/<email_removed>
This email sent to <email_removed>
| Related mails | Author | Date |
|---|---|---|
| Joan Lluch (casa) | Jun 8, 19:37 | |
| Kyle Sluder | Jun 8, 22:11 | |
| Joan Lluch (casa) | Jun 8, 23:04 | |
| Joan Lluch (casa) | Jun 8, 23:34 | |
| Joan Lluch (casa) | Jun 9, 00:02 | |
| Nathan Kinsinger | Jun 9, 03:06 | |
| carbonat | Jun 9, 11:09 | |
| Corbin Dunn | Jun 9, 18:00 | |
| carbonat | Jun 9, 18:21 | |
| Kyle Sluder | Jun 9, 18:45 |






Cocoa mail archive

