1

I'm attempting to run the Xcode project that was recently completed and I have one error to sort. Any help is greatly appreciated....

There is a Semantic Issue that appears before the error - The warning is as follows :

Undeclared selector 'boundingRectWithSize:options:atrributes:context'

The ARC Semantic Issue error is as follows :

No visible @interface for 'NSString' declares the selector 'boundingRectWithSize:options:attributes:context:'

The code is below...

// Since sizeWithFont() method has been depreciated, boundingRectWithSize() method has been used for iOS 7.

if ([NSString instancesRespondToSelector:@selector(boundingRectWithSize:options:attributes:context:)]) {
        NSMutableParagraphStyle *paragraphStyle = [NSMutableParagraphStyle new];
        paragraphStyle.lineBreakMode = NSLineBreakByClipping;
        CGRect requiredLabelRect = [self.textLabel.text boundingRectWithSize:contentViewSize
                                                                     options:NSStringDrawingUsesLineFragmentOrigin
                                                                  attributes:@{NSFontAttributeName:self.textLabel.font,
                                                                               NSParagraphStyleAttributeName: paragraphStyle
}
                                                                 context:nil];
rmaddy
  • 314,917
  • 42
  • 532
  • 579
  • What is your project's Base SDK and Deployment Target? – rmaddy Jul 11 '14 at 00:53
  • You can silence the warning (if that's what you want) by saying `[(id)(self.textLabel.text) bounding...` – Hot Licks Jul 11 '14 at 00:53
  • 1
    Could it be that you're accidentally compiling this code with an OS X (AppKit) SDK? The API you're using is UIKit specific. – microtherion Jul 11 '14 at 01:00
  • Have you tried compiling your code like this (using #if #endif directives): http://stackoverflow.com/questions/820142/how-to-target-a-specific-iphone-version and don;t let this code compilable for SDK other than ios 7. – NeverHopeless Jul 11 '14 at 04:24
  • ARGGGH!!! Updated Xcode to latest version and the error went away! – user3547575 Jul 11 '14 at 17:18

0 Answers0