Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error when calling a method: error use of undeclared identifier

Tags:

objective-c

So i have the below method declaration and definition,

  -(UIImageView *)returnImageView:(UIImageView *)myImageView color:(UIColor *)imageViewColor x:(int)xParameter y:(int)yParamater width:(int)widthParameter height:(int)heightParameter
{  
CGRect cellFrame = CGRectMake(xParameter, yParamater, widthParameter, heightParameter);
style:UITableViewStyleGrouped];
myImageView = [myImageView initWithFrame:cellFrame];
myImageView.backgroundColor =imageViewColor;
myImageView.opaque = YES;
return myImageView;
}

This method will return an image view.

I am trying to call it as

UIImageView *myImageViews;
UIColor *tableColor = [UIColor blueColor] ;
[self.view addSubview:[returnImageView:myImageViews color:tableColor x:17 y:10 width:290 height:230]; 

which is giving a compiler error use of undeclared identifier returnImageView. What is causing the error ?

Thanks

like image 605
Bisoux Avatar asked Feb 11 '12 15:02

Bisoux


People also ask

What does the error message undeclared identifier mean?

The identifier is undeclaredIf the identifier is a variable or a function name, you must declare it before it can be used. A function declaration must also include the types of its parameters before the function can be used.

What does use of undeclared identifier mean in C++?

The identifier is undeclared: In any programming language, all variables have to be declared before they are used. If you try to use the name of a such that hasn't been declared yet, an “undeclared identifier” compile-error will occur.


1 Answers

First of all a square bracket is missing after the last line of code.

Second you have to call "self" to get the method!

[self.view addSubview:[self returnImageView:myImageViews color:tableColor x:17 y:10 width:290 height:230]];

Third, did you declare your returnImageView method in the class-relative .h file?

-(UIImageView *)returnImageView:(UIImageView *)myImageView color:(UIColor *)imageViewColor x:(int)xParameter y:(int)yParamater width:(int)widthParameter height:(int)heightParameter;
like image 149
erond Avatar answered Oct 07 '22 03:10

erond