• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: blocks and id
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: blocks and id


  • Subject: Re: blocks and id
  • From: Mike Abdullah <email@hidden>
  • Date: Wed, 12 Dec 2012 12:02:02 +0000

On 12 Dec 2012, at 09:57, Andreas Grosam wrote:

>
> On 12.12.2012, at 10:19, Charles Srstka wrote:
>
>> On Dec 12, 2012, at 3:03 AM, Andreas Grosam <email@hidden> wrote:
>>
>>> How can I check at runtime whether an object (id) is actually a block, and not another kind of object?
>>
>> I don't think there's any good way of doing that right now. You could check the class of the block, but since the block classes are completely undocumented AFAIK, there's no guarantee that the class names won't change in some future release of OS X and break your code.
>>
>> Charles
>>
>
> Thanks for the reply. I feared that.
>
> Currently, I resort to
>
>
> if ([obj isKindOfClass: NSClassFromString(@"NSBlock")])
> …
>
> which evaluates to YES if `obj` is a block. However, NSBlock is not a public class, thus: NSClassFromString(@"NSBlock") which "works" as the time of writing in Mac OS, and returns a class whose name is "NSBlock" (the real block classes are named differently).

Why does your code care if some unknown object is a block? This is a strong sign of a bad design.


_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden


  • Follow-Ups:
    • Re: blocks and id
      • From: Jean Suisse <email@hidden>
    • Re: blocks and id
      • From: Andreas Grosam <email@hidden>
References: 
 >blocks and id (From: Andreas Grosam <email@hidden>)
 >Re: blocks and id (From: Charles Srstka <email@hidden>)
 >Re: blocks and id (From: Andreas Grosam <email@hidden>)

  • Prev by Date: Re: blocks and id
  • Next by Date: Re: blocks and id
  • Previous by thread: Re: blocks and id
  • Next by thread: Re: blocks and id
  • Index(es):
    • Date
    • Thread