I have been testing prior to submission of an update... from iOS4, and have run into the following... 1) creating PDFs from my app. 2) appears to be inconsistent, as I can create new PDFs without issue in most cases. 3) the crash log indicates a crash at line 341 of ExportView, which I have configured so that the only item on the line is a CFRangeMake. Note in the console that there is a value, as the same value is used in several lines.
A few notes: using Xcode 4.6, target is iOS6, fully ARC, testing on new iPad.
Any help with this would be greatly appreciated!!
I've removed some of the crash log and console log to shorten this post! Apologies for it's length even now!
Methods for the strings to be applied to the PDF creation:
- (CFMutableAttributedStringRef) CreateAttributedString:(int*) dateLength
titleLength:(int*) titleLength
{
NSLog(@"Current EntryIndex: %d", _entryIndex);
NSLog(@"Current Entry: %@", _currentEntry); // current entry is set from the parent view controller via PrepareForSegue
NSDateFormatter * dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"MMMM dd, yyyy, h:mm aaa"];
NSString * dateString = [dateFormatter stringFromDate:_currentEntry.created];
*dateLength = [dateString length];
NSLog(@"DateString: %@", dateString);
NSLog(@"2nd DateLength: %d", *dateLength);
NSString *title = _entryTitle;
*titleLength = [title length];
NSString *bodyString = _entryText;
NSString *contentString = [NSString stringWithFormat:@"%@\n\n%@\n%@", dateString, title, bodyString];
NSLog(@"TitleString: %@", title);
NSLog(@"BodyString: %@", bodyString);
NSLog(@"TitleLength: %d", *titleLength);
CFStringRef string = (__bridge CFStringRef)contentString;
CFMutableAttributedStringRef attributedContentString CFAttributedStringCreateMutable(kCFAllocatorDefault, 0);
CFAttributedStringReplaceString (attributedContentString,CFRangeMake(0, 0), string);
return attributedContentString;
}
- (void) SetTextFontName:(int)dateLength titleLength:(int)titleLength forAttributedString:(CFMutableAttributedStringRef) text
{
//date
CTFontDescriptorRef dateFontDescriptor = CTFontDescriptorCreateWithNameAndSize((__bridge CFStringRef)_entryDateTimeFontName, _entryDateTimeFontSize);
CTFontRef dateFont = CTFontCreateWithFontDescriptor(dateFontDescriptor, _entryDateTimeFontSize, NULL);
NSLog(@"Font entryDateTimeFontSize, line 329: %d", _entryDateTimeFontSize);
NSLog(@"DateFontDescriptor, line 329: %@", dateFontDescriptor);
CFAttributedStringSetAttribute(text, CFRangeMake(0, dateLength), kCTFontAttributeName, dateFont);
NSLog(@"DateLength... before crash: %d", dateLength);
NSLog(@"DateLength... crashing: %d", dateLength);
CFAttributedStringSetAttribute(text,
CFRangeMake(0, dateLength), // this is line 341...
kCTForegroundColorAttributeName,
_entryDateTimeColor.CGColor);
NSLog(@"Date length for line 332: %d", dateLength);
NSLog(@"Text for line 332: %@", text);
NSLog(@"Font name... font attributes line 332: %@", dateFont);
NSLog(@"Date length for line 333: %d", dateLength);
NSLog(@"Text for line 333: %@", text);
NSLog(@"Date color for line 333: %@", _entryDateTimeColor.CGColor);
CFRelease(dateFontDescriptor);
CFRelease(dateFont);
//title
CTTextAlignment alignment = kCTCenterTextAlignment;
CTParagraphStyleSetting _settings[] = {{kCTParagraphStyleSpecifierAlignment, sizeof(alignment), &alignment}};
CTParagraphStyleRef paragraphStyle = CTParagraphStyleCreate(_settings, sizeof(_settings) / sizeof(_settings[0]));
CFAttributedStringSetAttribute(text, CFRangeMake(dateLength, dateLength + titleLength), kCTParagraphStyleAttributeName, paragraphStyle);
CTFontDescriptorRef titleFontDescriptor = CTFontDescriptorCreateWithNameAndSize((__bridge CFStringRef)_entryTitleFontName, _entryTitleFontSize);
CTFontRef titleFont = CTFontCreateWithFontDescriptor(titleFontDescriptor,_entryTitleFontSize, NULL);
NSLog(@"TitleFontDescriptor: %@", titleFontDescriptor);
CFAttributedStringSetAttribute(text, CFRangeMake(dateLength, dateLength + titleLength), kCTFontAttributeName, titleFont);
CFAttributedStringSetAttribute(text, CFRangeMake(dateLength, dateLength + titleLength), kCTForegroundColorAttributeName, _entryTitleColor.CGColor);
NSLog(@"TitleColor: %@", _entryTitleColor);
NSLog(@"Titlecolor: %@", _entryTitleColor.CGColor);
CFRelease(titleFontDescriptor);
CFRelease(titleFont);
//content
CTFontDescriptorRef fontDescriptor = CTFontDescriptorCreateWithNameAndSize((__bridge CFStringRef)_entryTextFontName, _entryTextFontSize);
CTFontRef font = CTFontCreateWithFontDescriptor(fontDescriptor, _entryTextFontSize, NULL);
CFAttributedStringSetAttribute(text, CFRangeMake(dateLength + titleLength+2, CFAttributedStringGetLength(text) - dateLength - titleLength - 2), kCTFontAttributeName, font);
CFAttributedStringSetAttribute(text, CFRangeMake(dateLength + titleLength+2, CFAttributedStringGetLength(text) - dateLength - titleLength - 2), kCTForegroundColorAttributeName, _entryTextColor.CGColor);
CFRelease(fontDescriptor);
CFRelease(font);
}
Crash Log:
Incident Identifier: D5D15E15-8A4C-4850-B751-9F1D546F1F71
CrashReporter Key: 54bfdcf0248d463bc97ac986b7553405b3b0f8b9
Hardware Model: iPad3,4
Process: TabletJournal [9876]
Path: /var/mobile/Applications/109DCB8E-22D1-45E4-A347- 1B1F211F9044/TabletJournal.app/TabletJournal
Identifier: TabletJournal
Version: ??? (???)
Code Type: ARM (Native)
Parent Process: launchd [1]
Date/Time: 2013-03-20 15:42:11.412 +0100
OS Version: iOS 6.1.2 (10B146)
Report Version: 104
Exception Type: EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x000000000000defe
Crashed Thread: 0
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 CoreFoundation 0x3272b4e0 0x32693000 + 623840
1 CoreFoundation 0x3271bc2c 0x32693000 + 560172
2 CoreFoundation 0x3277043c 0x32693000 + 906300
3 CoreFoundation 0x32697b4e 0x32693000 + 19278
4 CoreFoundation 0x32705e5e 0x32693000 + 470622
5 TabletJournal 0x0005f3d8 -[ExportView SetTextFontName:titleLength:forAttributedString:] (ExportView.m:341)
6 TabletJournal 0x0005ed58 -[ExportView saveJournalToPDF:andName:] (ExportView.m:196)
7 TabletJournal 0x0005ec8a -[ExportView pdfButtonTapped:] (ExportView.m:179)
8 UIKit 0x3464f082 0x34561000 + 974978
9 UIKit 0x3464f036 0x34561000 + 974902
10 UIKit 0x3464f010 0x34561000 + 974864
11 UIKit 0x3464e8c6 0x34561000 + 972998
12 UIKit 0x3464edb4 0x34561000 + 974260
13 UIKit 0x345775f4 0x34561000 + 91636
14 UIKit 0x345648dc 0x34561000 + 14556
15 UIKit 0x345641ea 0x34561000 + 12778
16 GraphicsServices 0x362575f4 0x36251000 + 26100
17 GraphicsServices 0x36257222 0x36251000 + 25122
18 CoreFoundation 0x3272a3e4 0x32693000 + 619492
19 CoreFoundation 0x3272a386 0x32693000 + 619398
20 CoreFoundation 0x3272920a 0x32693000 + 614922
21 CoreFoundation 0x3269c238 0x32693000 + 37432
22 CoreFoundation 0x3269c0c4 0x32693000 + 37060
23 GraphicsServices 0x36256336 0x36251000 + 21302
24 UIKit 0x345b82b4 0x34561000 + 357044
25 TabletJournal 0x0002e35a main (main.m:22)
26 libdyld.dylib 0x3aa02b1c 0x3aa01000 + 6940
Thread 0 crashed with ARM Thread State (32-bit):
r0: 0x3ac440f0 r1: 0x00000000 r2: 0x00001200 r3: 0x3ac2ce44
r4: 0x00000000 r5: 0x1ea52580 r6: 0x3272b4d9 r7: 0x2fdd26c4
r8: 0x3ac47940 r9: 0x00000012 r10: 0x3acacd88 r11: 0x1ea52580
ip: 0x00010201 sp: 0x2fdd26c0 lr: 0x3271bc2f pc: 0x3272b4e0
cpsr: 0xa0000030
Console log... the important parts:
Mar 20 15:50:54 Marcs-iPad TabletJournal[9947] <Warning>: SettingsModel, entries: (
"<JournalEntry: 0x1e296310>",
"<JournalEntry: 0x1e24be00>")
Mar 20 15:50:54 Marcs-iPad TabletJournal[9947] <Warning>: Export Loading
Mar 20 15:50:55 Marcs-iPad TabletJournal[9947] <Warning>: Current EntryIndex: 1
Mar 20 15:50:55 Marcs-iPad TabletJournal[9947] <Warning>: Current Entry: <JournalEntry: 0x1e296310>
Mar 20 15:50:55 Marcs-iPad TabletJournal[9947] <Warning>: DateString: marzo 20, 2013, 3:41 PM
Mar 20 15:50:55 Marcs-iPad TabletJournal[9947] <Warning>: 2nd DateLength: 23
Mar 20 15:50:55 Marcs-iPad TabletJournal[9947] <Warning>: TitleString: Test2
Mar 20 15:50:55 Marcs-iPad TabletJournal[9947] <Warning>: BodyString: I’m here in the Istanbul airport again, for another 5-hour layover! Plane is suppose to take off at 2:50 pm! Next time, I’m going to make sure my layovers are not more than 2 hours. That’ll leave room for delays. I ate a small pizza at this “Italian” diner. It was actually pretty good. Later, I’ll have to compare it with real Italian pizza. I’m dead tired. Gotta get some caffeine! Got the caffeine! Yow! I should wake up in a few minutes! There are posters of Italia here and I’ve found a couple of places I’d like to see. Lago D’Orta di Piemonte, Galleria Borghese di Lazio- Roma, Pisa.
Mar 20 15:50:55 Marcs-iPad TabletJournal[9947] <Warning>: TitleLength: 5
Mar 20 15:50:55 Marcs-iPad TabletJournal[9947] <Warning>: Font entryDateTimeFontSize, line 329: 13
Mar 20 15:50:55 Marcs-iPad TabletJournal[9947] <Warning>: DateFontDescriptor, line 329:
CTFontDescriptor <attributes: <CFBasicHash 0x1d518f50 [0x3ac440f0]>{type = mutable dict, count = 2,
entries =>
1 : <CFString 0x3acad758 [0x3ac440f0]>{contents = "NSFontNameAttribute"} = <CFString 0x1e07a880 [0x3ac440f0]>{contents = "Copperplate"}
2 : <CFString 0x3acad8c8 [0x3ac440f0]>{contents = "NSFontSizeAttribute"} = <CFNumber 0x1d5cb1d0 [0x3ac440f0]>{value = +13.0000000000, type = kCFNumberFloat32Type}}
>
Mar 20 15:50:55 Marcs-iPad TabletJournal[9947] <Warning>: DateLength... before crash: 23
Mar 20 15:50:55 Marcs-iPad TabletJournal[9947] <Warning>: DateLength... crashing: 23
Mar 20 15:50:56 Marcs-iPad ReportCrash[9951] <Notice>: Formulating crash report for process TabletJournal[9947]
Mar 20 15:50:56 Marcs-iPad com.apple.launchd[1] (UIKitApplication:com.creativeappgroup.TabletJournalTM[0xe437][9947]) <Warning>: (UIKitApplication:com.creativeappgroup.TabletJournalTM[0xe437]) Job appears to have crashed: Trace/BPT trap: 5
Mar 20 15:50:56 Marcs-iPad ReportCrash[9951] <Error>: libMobileGestalt copySystemVersionDictionaryValue: Could not lookup ReleaseType from system version dictionary
Mar 20 15:50:56 Marcs-iPad backboardd[25] <Warning>: Application 'UIKitApplication:com.creativeappgroup.TabletJournalTM[0xe437]' exited abnormally with signal 5: Trace/BPT trap: 5
Mar 20 15:50:56 Marcs-iPad ReportCrash[9951] <Notice>: Saved crashreport to /var/mobile/Library/Logs/CrashReporter/TabletJournal_2013-03-20-155055_Marcs-iPad.plist using uid: 0 gid: 0, synthetic_euid: 501 egid: 0
It turns out that the libModileGestalt had nothing do with the crashing. Found out via a tip on Apple forums that the CGColor was probably nil. After isolating and installing log statements before the actual call, that it was indeed the case. In fact, all of the colors... text, title and date were coming over as NULL. So, I've got the crashing to stop by installing a test and apply statement in the create PDF method. Now... to find out why the colors are not being passed over!
User contributions licensed under CC BY-SA 3.0