• 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: How to remove 'not found in protocol' compiler warning
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to remove 'not found in protocol' compiler warning


  • Subject: Re: How to remove 'not found in protocol' compiler warning
  • From: Sherm Pendley <email@hidden>
  • Date: Fri, 12 Nov 2010 09:17:00 -0500

On Fri, Nov 12, 2010 at 9:09 AM, Paul Johnson <email@hidden> wrote:

> I'm getting a compiler warning message at the following line of code:
>
>    NSArray *selectedObjects = [[secondTableView dataSource]
> selectedObjects];
>
> The warning message is <'selectedObjects' not found in protocol>.
>

Note that NSTableView's -dataSource returns an object of type
id<NSTableViewDataSource>. So, the compiler knows nothing about the object
other than its protocol conformance. Since -selectedObjects isn't part of
the protocol, it gives this warning.


> Can someone suggest what I need to do to remove the warning?
>

Use a type cast to tell the compiler what class the data source really is:

  NSArray *selectedObjects = [(MyDataSourceClass*)[secondTableView
dataSource] selectedObjects];

sherm--

--
Cocoa programming in Perl:
http://camelbones.sourceforge.net
_______________________________________________

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: How to remove 'not found in protocol' compiler warning
      • From: Thomas Davie <email@hidden>
References: 
 >How to remove 'not found in protocol' compiler warning (From: Paul Johnson <email@hidden>)

  • Prev by Date: How to remove 'not found in protocol' compiler warning
  • Next by Date: Re: How to remove 'not found in protocol' compiler warning
  • Previous by thread: How to remove 'not found in protocol' compiler warning
  • Next by thread: Re: How to remove 'not found in protocol' compiler warning
  • Index(es):
    • Date
    • Thread