Re: This worked in Panther...
Re: This worked in Panther...
- Subject: Re: This worked in Panther...
- From: Fritz Anderson <email@hidden>
- Date: Mon, 20 Jun 2005 10:37:21 -0500
On 20 Jun 2005, at 10:14 AM, Jerry LeVan wrote:
I did a clean and rebuild and sure enough I get a number of errors
typically
like the following:
current = [ [theController rotation] floatValue]; <--- error on this
warning: invalid receiver type 'float'
error: cannot convert to a pointer type
where the above occurs in a subclassed image view.
...
In the KeyImageView.h file I have:
@interface KeyImageView : NSImageView
{
IBOutlet id theController; // provides access to main
controller object
}
In my main controller.h class I have:
IBOutlet id rotation; // pointer to the rotation slider
and
- (NSSlider*)rotation; // returns pointer to
rotation slider
Objective-C frets when messages with the same selector have different
return types. NSEvent has a -rotation method that returns float, and
on that basis, the compiler assumes the result of [theController
rotation] is float.
I'm a bit surprised the compiler did not warn you of the ambiguity,
and that it was choosing between different -rotation methods.
The solution is to provide a more-specific type than id for
theController, either in its declaration or by casting at the
rotation message. The compiler will then know to choose your
controller's semantics for the message instead of NSEvent's.
-- F
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden