Xcode 6.3 (and 6.2) reaches a breakpoint at [UIFont fontWithName: size:]

In My iOS application, I use the (DKTheme) class to keep fonts and images in a centralized location. my implementation looks like this.

+ (instancetype)theme { static DKTheme *_theme = nil; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ _theme = [[DKTheme alloc] init]; }); return _theme; } - (id)init { self = [super init]; if (self) { [self setupTheme]; } return self; } - (void)setupTheme { // some code here self.smallButtonFont = [UIFont fontWithName:@"Helvetica-Bold" size:13.0f]; //some code here } 

And when I run this code on the device (iPhone 5C, iOS8.3 and iOS8.2), xcode hits the breakpoint on the line self.smallButtonFont = [UIFont fontWithName:@"Helvetica-Bold" size:13.0f]; , if I click the continue button, the application continues to work without failures and the font property ( self.smallButtonFont ) is successfully initialized.

Breakpoint

Call stack

and I noticed one more thing: I have several calls [UIFont fontWithName: size:]; , and the breakpoint is only the first time. (if I comment on the first, and then the next method call hits the breakpoint). it really annoys this checkpoint problem, any help would be appreciated.

+8
ios objective-c iphone xcode xcode6
source share
5 answers

You added a breakpoint exception in Xcode and set it to break for all types of exceptions, C ++ and Objective-C. The problem is that C ++ code sometimes uses exceptions for non-exceptional situations. It can use it as a form of flow control or return a β€œfailure” from a function.

Unless you have a special C ++ exception that needs to be debugged because it really causes the problem, it might be best to set this breakpoint to just override Objective-C exceptions rather than C ++ exceptions. C ++ exceptions can be safely ignored.

+18
source share

This always happens when you add a breakpoint All Exceptions. Here you only need to add an objective-c breakpoint. Follow these steps:

  • Select Breakpoints debugger, right click on "All Exceptions".

enter image description here

  1. Now select Change Breakpoint

  2. Change the type of exception to "Objective-c Exception"

enter image description here

+3
source share

At first. Of course, this is the exception breakpoint. You can add or remove it in the Breakpoints tab. My screenshot will help you with this.

enter image description here

Reason for generating these exceptions:

You have some default fonts in iOS. If you try to create love with a missing font name. You see such an exception. You may be using a different font name in your code. I mean not only @ "Helvetica-Bold". And now you have a question: how can I now, is the font available in my OS. You can print all available fonts using this method:

 - (void)fontsList { NSArray *familyNames = [[NSArray alloc] initWithArray:[UIFont familyNames]]; NSArray *fontNames; NSInteger indFamily, indFont; for (indFamily=0; indFamily<[familyNames count]; ++indFamily) { NSLog(@"Family name: %@", [familyNames objectAtIndex:indFamily]); fontNames = [[NSArray alloc] initWithArray:[UIFont fontNamesForFamilyName:[familyNames objectAtIndex:indFamily]]]; for (indFont=0; indFont<[fontNames count]; ++indFont) { NSLog(@" Font name: %@", [fontNames objectAtIndex:indFont]); } } } 

Sincerely. And please add some information if you still have this problem.

+1
source share

If this is not the case, then you set a breakpoint - this may be due to method calls inside init. unsafe calls for yourself

Also see my notes on caching and downloading fonts .

0
source share

I also had this problem, and I solved it without changing the breakpoint settings. In my case, the problem was that my application had an infrastructure in which the provided font was indicated in the info.plist file, which was also indicated as the provided font by the application itself (in Fonts provided by application ). Duplicate removal resolves this issue.

0
source share

All Articles