Q:

Possible to cast when sending a message in objective-c?

I have:
[[[[self navigationItem] leftBarButtonItem] customView] setTitle:@" Create "];

Which is triggering a warning "'UIView' may not respond to '-setTitle:'". I've tried:
[[[[self navigationItem] leftBarButtonItem] (UIButton*)customView] setTitle:@" Create "];

And get errors when I do this. 0I also tried casting with (id) and that didn't work either.  I know I could probably just store the customView in a UIButton and go from there, but just wondering if it's possible to cast within a message like this?

A:

Think about what you are casting. Try this
[(UIButton*)[[[self navigationItem] leftBarButtonItem] customView] setTitle:@" Create "];

The difference in this line and your line is that you should not cast a property (e.g. customView) but rather the returned object on which you are about to call a method.

