views:

479

answers:

2
+2  A: 

This warning usually means your signature may be different or you haven't declared a prototype for your method.

For instance, you may have done something like this:

// Prototype
-(void) foo:(float)bar;

// Calling the function
int blargh = 3;
[myClass bar:blargh];

You see how the signatures don't match? Usually, this is the problem when I get the warning. Though you may have neglected to prototype it at all, which results in the same problem. Objective-c will accept any messages you pass to an object, even if it technically wasn't specified by you.

Sam
Ok, You're Right The Prototype is different, but If i change the prototype it will no longer work as it is important. You may want to look at the code (http://fwdr.org/h8xf) to see if there is another way to fix the problem or something else I need to change.
Joshua
Perhaps you aren't passing the correct parameters to your function? I think I will understand better once I can see the signature for your -objectArray method for that class. It may require a parameter or something that you haven't passed in.
Sam
I am unsure whether or not I have a signature for my -objectArray method. Can you show me how to add a signature?
Joshua
This is the line of code where the error came up: if ([[self objectArray] indexOfObject:rootObj] % 2)
Joshua
Yes, that's what I surmized. I think the problem here is that you are trying to call the "objectArray", but your signature does not match. Looks like you are attempting to get an NSArray from the containing class. However, your class either doesn't support this conversion, or you are not extending something you need to be extending. I can better help if you showed me your .h file for this class?
Sam
Jason's solution is beautiful, btw.
Sam
+2  A: 

From your code, it looks like you are accessing the objectArray property of self. Do you have that defined in your .h file?

@interface DragController : UIViewController
{
    NSArray* objectArray;
}
@property (nonatomic, retain) NSArray* objectArray;

If the @property is not present, then your class does not respond to [self objectArray]. You only need the property if you need other objects to access it. If you just want to access the instance variable, you can simply use objectArray by itself, so replace [[self objectArray] indexOfObject... with simply [objectArray indexOfObject... and the warning should go away. If objectArray really is a method, it should look like this in your .h file, after the { instance variables } section:

-(NSArray*)objectArray;

And in the .m file:

-(NSArray*)objectArray
{
    // return the array here
}
Jason
When I change it to [objectArray objectAtIndex I get an error saying 'objectArray' un-declared. What should I do now to fix this?
Joshua
You should give your object an instance variable called objectArray, it sounds like.
Chuck
Should It Be An IBOutlet?
Joshua
No, anything with an IB in front is for InterfaceBuilder only.
Sam
Hold on, if you haven't defined your objectArray, what are you using it for? Are you trying to access something you've defined elsewhere?
Sam
I got this code off CocoaDev to try an make the parent in an Outline View have a colored background. So I am un-sure how this was made.
Joshua
You'll need to consult with the original author on how to use the code snippet. From the code you pasted, it appears that objectArray is declared as a property in the Outline View controller and is the source for the view's row items. Also, see the perils of this type of coding practice at http://stackoverflow.com/questions/891419/page-fault-programming-parrot-programming .
Jason
I don't think I'll be able to, although there is an Email Address the post dates back to 2004. But I'll give it a go.
Joshua
Just tried to email Him, but the Email Address no longer exists. So I don't really know what to do now.
Joshua
Joshua, I think we can help, but you'll have to tell us what you are trying to do. We unfortunately can't explain a code snippet we don't know about...
Sam