Is it really ignoring the return value of a method in objective-c?

For example, when I call a method that returns a value, but it doesn’t interest me at all, can I safely ignore it?

An example, not:

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

... do the following:

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

I do not need CGSize size, but only actualFontSizethat is transmitted by reference. Now the problem is that Xcode gives me a warning if I don't read size. I do not want to suppress these warnings, and at the same time I do not want them at all.

So I'm wondering if this is good if I just don't assign the return value to anyone?

+3
source share
1 answer

, Xcode . , .

, void:

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

Source: https://habr.com/ru/post/1735820/


All Articles