views:

347

answers:

2

Hey

When I run my application it shows one warning message:

warning:passing argument 1 of 'presentModalViewController:animated'
from distinct objective - c type

How do I resolve this warning? I've used presentModalViewController:animated many times previously in my application.

Please help me.

Thanks in advance

+2  A: 

That method expects it's first argument to be of type UIViewController *. What's likely happening is that you're either passing the wrong object to that method, or you haven't imported the header file for your custom view controllers in the file in which you're calling that method.

kubi
A: 

Your problem is that you've defined the view controller you're passing like:

UIViewController myViewController=... // <= you've defined it as the struct that defines a class

(note the missing asterisk) instead of:

UIViewController *myViewController=... // <= defined as a pointer to the memory address of an instance. 
TechZen
You can't have a variable of type UIViewController in Apple's dialect of Objective-C — the declaration itself is an error.
Chuck
@Chuck, Hmmm, this works: `UIViewController *myViewController =[[UIViewController alloc] initWithNibName:@"aNibName" bundle:[NSBundle mainBundle];` or did you mean something else?
TechZen
Yes, I meant a variable of type `UIViewController` rather than `UIViewController*` — note the missing asterisk — like you suggested Rajendra was doing. You won't get an Objective-C type warning, you'll get an error that objects on the stack are illegal.
Chuck
Oh, who were you talking to him or me?
TechZen
@Chuck, Thank. I got the proper knowledge about variables object.
RRB