Re: Selector Not Recognized
Re: Selector Not Recognized
- Subject: Re: Selector Not Recognized
- From: Nir Soffer <email@hidden>
- Date: Thu, 13 Jul 2006 02:25:00 +0300
On 12/07/2006, at 01:30, David Alter wrote:
//Make an instance on MyParent
MyParent * parent = [[MyParent alloc] init];
//Cast MyParent into a pointer of MySub.
MySub * sub = (MySub *) parent;
//Access a method of MySub.
int val = [sub getSomeDataPlusOne]; // It chokes here with
"selector not recognized"
Objective C is simple:
The sub class method is just:
- (int) someDataPlusOne
{
return somedata + 1 // or did you mean ++somedata ?
}
Sub class may access its super class instance variables (unless you
declare them private).
Note that I renamed getSomeDataPlusOne - get is used only for methods
that return a value by reference:
- (void)getSomeDataPlusOne:(int *)value
{
if (value != NULL) *value = somedata + 1;
}
int value;
[sub getSomeDataPlusOne:&value];
Best Regards,
Nir Soffer
_______________________________________________
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