Re: selector not recognized
Re: selector not recognized
- Subject: Re: selector not recognized
- From: a984984 <email@hidden>
- Date: Wed, 30 Jun 2004 04:11:46 -0700
I realize I wasting time of great many good people here
so unless you are as ignorant as I am skip.
---
maoosxguru wrote me with this:
>
The error is yours:
>
mydelegate is not an instance of Myclass but the Myclass class
>
itself, so the source of the problem is in the initialization of
>
mydelegate or if you really want a class method change the
>
method declaration from - (NSMutableArray*)ArgArray; to
>
+ (NSMutableArray*)ArgArray.
>
>
Myclass mc* = mydelegate; is either a typo either a big
>
mistake:
>
>
Myclass *mc = mydelegate ????
>
>
or maybe what you rellay want is
>
Class mc = [mydelegate class] ;
>
>
------------
This was almost it. Using + declaration of ArgArray and Class mc =
[mydelegate class]
>
NSMutableArray *aArr = [mc ArgArray];
works in the sense of being able to find ArgArray method but at the run
time ArgArray method crashes with "out of scope" message. So far unable
to find out what the heck out-of scope for class method is.
---
The solution I found is this. (following Apple example)
Here is my original Myclass:
@interface Myclass : NSObject
{
NSMutableArray *array;
}
+ (NSMutableArray*)ArgArray;
@end
I wanted ArgArray to return array. Follow it now with:
struct MyclassStruct {
@defs(Myclass)
} *public;
Then in another object that has an outlet mdelegate connected to the
instance of Myclass I go back to my original (sorry maoosxguru !)
Myclass *myinstance = mdelegate;
which I know for sure (debugger dump) contains reference to my instance
of Myclass and I write
public = (struct MyclassStruct *) myinstance;
after which
NSMutableArray *arr = public->array;
gives me my array w/o complaining.
-----
Thanks to all.
---
BTW - given how convoluted this C-O/CO combo appears to be, can a lazy
person like me expect to learn something in a reasonable time frame?
Without having to get as dirty as above?
I went briefly through Learning Cocoa but after seeing this gem of
example code:
..
while ((anItem = [itemEnum nextObject]))
if ([anItem isKindOfClass:[ToDoItem class]] &&
..
with no attempt whatosvever to explain why one needs
isKindOfClass:[ToDoItem class]]
and what the heck does it do, I gave up.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.