Update deprecated code

This question already has an answer here:

Can you please help with adopting code to iOS 7?
I have code:

size = [string sizeWithFont:font

But Xcode says that sizeWithFont:font sizeWithFont:font and lineBreakMode deprecated in iOS 7.

Help me please with update this line of code.

1 Solution

Use sizeWithAttributes: which takes an NSDictionary.

CGSize fontSize = [string sizeWithAttributes: @{NSFontAttributeName: [UIFont fontWithName:@"Helvetica" size:15]}];