Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Instance method not found (return type defaults to id)

I am taking a warning from Xcode. Here is the code

 DeviceList *dList = (DeviceList* )[[User thisUser] devices];
 [dList getListId];

The warning states that instance method -getListId is not found. However the method exists in my source code

- (NSString*) getListId
{
    T
    if ( ... != nil)
    {
        return ...;
    }
    else
    {
        return @"";
    }
}

I cannot figure out what the problem is when I am calling the method.

like image 546
cateof Avatar asked Oct 31 '12 08:10

cateof


2 Answers

have you added a declaration for this method in the .h file, and if so, have you imported the .h into the file you are trying to call this method?

this error is basically the compiler saying it can't find the method declaration, so it doesn't know what to expect the return type to be.

like image 180
wattson12 Avatar answered Nov 04 '22 08:11

wattson12


in your DeviceList.h , make sure you have

@interface DeviceList : Parent
- (NSString*) getListId;
..
..
@end

the warning occurs when your method is not declared in your header file and you try to call it outside your (self) class.

like image 24
janusfidel Avatar answered Nov 04 '22 06:11

janusfidel