Re: How to remove 'not found in protocol' compiler warning
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