Q:

Expected "]" in method called from AppDelegate

I'm trying to call a method in my AppDelegate class using the following code. The compiler is showing an "Expected ]" error, no matter how many ] characters I put in.
What am I doing wrong here?
[[(MyAppDelegate *)[[UIApplication sharedApplication] delegate] authenticateUser(usernameField.text, passwordField.text)]];

A:

The main problem is the code has the app delegate trying to call a function, not a method.
[[(MyAppDelegate *)[[UIApplication sharedApplication] delegate] authenticateUser(usernameField.text, passwordField.text)]];

rewriting (and removing the extra []:
MyAppDelegate *appDelegate = (MyAppDelegate *)[[UIApplication sharedApplication] delegate]

[appDelegate authenticateUser(usernameField.text, passwordField.text)];

We see that while appDelegate expects a method it finds a function.
Change authenticateUser to be a method.
Ex:
MyAppDelegate *appDelegate = (MyAppDelegate *)[[UIApplication sharedApplication] delegate]
[appDelegate authenticateUser:usernameField.text pass:passwordField.text];

