toast-notifications-ios icon indicating copy to clipboard operation
toast-notifications-ios copied to clipboard

sizeWithFont:constrainedToSize:' is deprecated

Open ik2wxx opened this issue 11 years ago • 2 comments

/iToast.m:74:26: 'sizeWithFont:constrainedToSize:' is deprecated: first deprecated in iOS 7.0 - Use -boundingRectWithSize:options:attributes:context:

Please fix, thank you Roberto

ik2wxx avatar Nov 25 '13 10:11 ik2wxx

Based on an answer over at StackOverflow, I replaced line 74 with the following:

  NSDictionary *attributesDictionary = [NSDictionary dictionaryWithObjectsAndKeys:
                                          font, NSFontAttributeName,
                                          nil];
  CGSize textSize = [text boundingRectWithSize:CGSizeMake(280, 60)
                                          options:NSStringDrawingUsesLineFragmentOrigin
                                       attributes:attributesDict

I'll submit a pull request for this, though this would make the code require iOS 7. The README doesn't specify what version(s) of iOS are supported, but for the sake of iOS 6, I'll add a respondsToSelector: call.

brockboland avatar Jan 01 '14 21:01 brockboland

Actually, you'll still get the warning even with the respondsToSelector:, so I'm not going to bother with a PR. Either:

  • Support iOS 6, and iOS 7 devs deal with warning, or
  • Only support iOS 7, and I'm not sure @ecstasy2 wants to do that.

brockboland avatar Jan 01 '14 21:01 brockboland