I want to populate NSDictionary with text from UITextFields. Here is what I try
[self delegate]populate:[NSDictionary dictionaryWithObjectsAndKeys:
[self.username.text], @"username",
[self.password.text], @"password"
nil];
But I get expected identifier.
What is wrong here ? Why can’t pass [self.*] directly ?
I have tried also
[self delegate]populate:[NSDictionary dictionaryWithObjectsAndKeys:
[NSString stringWithFormat:@"%@", [self.username.text]], @"username",
[NSString stringWithFormat:@"%@", [self.password.text]], @"password"
nil];
still not working
[self.username.text]is invalid syntax.The message sending syntax is
[object message]. The dot syntax isobject.property. Since a property access usually results in an object, you can combine them, but there still needs to be a message part. If you just put the dot syntax inside brackets, you’re missing the message part:[object.property <missing message>].Change it to either
self.username.text(no brackets) or[self.username text].As bdesham points out (I assumed this was just a typo here), you’re missing braces around the whole snippet.
[self delegate]is the object to which you’re sending the messagepopulate: