In My iOS Application im using a class (DKTheme) to keep my fonts and images in a centralised place. 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 in device (iPhone 5C, iOS8.3 and iOS8.2), xcode hits breakpoint on the line self.smallButtonFont = [UIFont fontWithName:@"Helvetica-Bold" size:13.0f];
if i click continue execution button, application continue running without crashing and my font property(self.smallButtonFont
) is successfully initialised.
and i noticed one more thing, i have several [UIFont fontWithName: size:];
calls and breakpoint hits only first time call.(if i comment the first one then next method call hits the break point). it is really annoying this breakpoint issue, any help would be thankful.
You have added a breakpoint exception in Xcode and configured it to break on all exception types, C++ and Objective-C. The problem is that C++ code sometimes uses exceptions for non-exceptional situations. It may use it just as a form of flow control or returning "failure" from a function.
Unless you have a specific C++ exception that you need to debug because it's actually causing a problem, probably best to configure that breakpoint to just break on Objective-C exceptions and not C++ exceptions. The C++ exceptions can be safely ignored.
This always happens when you added All Exceptions breakpoint. Here, you need to add only objective-c breakpoint. Follow these steps:
Now select click "Edit Breakpoint"
Change Exception type to "Objective-c Exception"
At first. Of course it is exception breakpoint. You can add or delete it in "Breakpoints tab". My screenshot can help you with it.
Reason of generation this exceptions:
You have some default fonts in iOS. If you try to generate fond with unavailable font name. You see exception like this. Maybe in your code you use some another font name. I mean not only @"Helvetica-Bold". And now you have a question: How can i now, Is 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]);
}
}
}
Best regards. And please add some info if you still have this problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With