views:

73

answers:

1

For example, when I call a method that returns an value, but I'm not interested in this at all, can I safely ignore that?

Example, instead of:

CGSize size = [str sizeWithFont:myFont minFontSize:19.0f actualFontSize:&actualFontSize forWidth:150.0f lineBreakMode:UILineBreakModeClip];

...do this:

[str sizeWithFont:myFont minFontSize:19.0f actualFontSize:&actualFontSize forWidth:150.0f lineBreakMode:UILineBreakModeClip];

I don't need the CGSize size but only actualFontSize, which is passed in by reference. Now the problem is that XCode gives me a warning if I don't read size. I don't want to surpress those warnings, and at the same time I don't want them at all.

So I wonder if it's okay if I just don't assign the return value to anything?

+5  A: 

I didn't think Xcode worried about it at all. No, it's not going to do anything bad.

If you want to cleanly shut up the warning, cast the return value to void:

(void)[str sizeWithFont:myFont minFontSize:19.0f actualFontSize:&actualFontSize forWidth:150.0f lineBreakMode:UILineBreakModeClip];
zneak