我剛剛得到一個崩潰報告(在發射),提交我的應用程序在Mac App Store,審覈後:誤差的NSDictionary - 「對象計數從計數不同鍵」
Application Specific Information:
objc[1832]: garbage collection is ON
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSDictionary initWithObjects:forKeys:]: count of objects (0) differs from count of keys (2)'
terminate called throwing an exception
abort() called
這是代碼的一部分,我懷疑:
- (NSMutableDictionary*)getNewChapterWithTitle:(NSString*)title
{
if (title==nil) title = [NSString stringWithFormat:@"Chapter %d",[[self appChapters] count]+1];
// Align Justify
NSMutableParagraphStyle * paragraphStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
[paragraphStyle setAlignment:NSJustifiedTextAlignment];
// Set Font
NSDictionary *font = [NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:[NSFont fontWithName:@"Garamond" size:15.0],paragraphStyle, nil] forKeys:[NSArray arrayWithObjects:NSFontAttributeName, NSParagraphStyleAttributeName, nil]];
NSString* lipsum = @"\nLorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc consequat fermentum faucibusPhasellus ac consequat metus. Sed at lectus sit amet tellus vulputate mollis vel suscipit metus. Nulla a sapien purus. Aenean sollicitudin lacus varius nisi faucibus nec lacinia mauris fermentum. Aliquam euismod quam rhoncus ipsum pulvinar quis condimentum magna imperdiet. Nullam augue leo, dictum tincidunt ullamcorper id, porta in lorem. Duis in vestibulum nisl.\
\n\n\
Donec imperdiet dignissim massa, at ultricies enim dignissim at. Etiam pharetra neque quis quam condimentum vitae viverra nisl volutpat. Vivamus urna ante, ultrices ut tincidunt id, auctor id est. Nunc eget diam purus, at viverra orci. Maecenas eu magna mi, id venenatis arcu. Maecenas ornare, tortor sit amet gravida placerat, diam urna lacinia nunc, a dictum arcu libero sed metus. Nulla pulvinar sapien vitae lectus faucibus quis tempus elit volutpat. Integer facilisis interdum lectus, sit amet dapibus enim mattis non. Donec sed pulvinar risus. Mauris in nulla urna, sit amet placerat turpis. Proin felis erat, pretium sed pharetra vel, tincidunt quis tortor. Donec ut nisi dui. Pellentesque gravida gravida justo, quis convallis leo euismod in. Nam pretium accumsan sapien ac interdum.";
NSMutableAttributedString* theLipsum = [[NSMutableAttributedString alloc] initWithString:lipsum attributes:font];
return [[NSMutableDictionary dictionaryWithObjectsAndKeys:
[title retain],@"title",
[theLipsum retain],@"content",
[NSNumber numberWithInt:0],@"isMarkdown",
nil] retain];
}
你是否發現上述任何「明顯」錯誤? (它被稱爲像4-5倍,從awakeFromNib
,所以我想這是罪魁禍首...)
提示:的retain
■找得到報告後增加;我不知道它是否會幫助儘管...
@Remizorrr夥計們,非常感謝!甚至沒有想到這一點;將檢查它是如何去的,並且如果需要將會替換問題中的字體。 ;-) –