• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Problem recovering NSAttributedString from NSData
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Problem recovering NSAttributedString from NSData


  • Subject: Problem recovering NSAttributedString from NSData
  • From: "email@hidden" <email@hidden>
  • Date: Mon, 26 Jan 2009 21:46:36 +0000

My app uses GC and a simple Core Data XML store.

The model data contains an NSData representation of an RTFD attributed string.
Once fetched from the store the NSData rep is converted back to an NSAttributed string:


- (void)updateMessageStringValue
{
NSData *messageData = self.message;

if (![messageData isKindOfClass:[NSData class]]) {
NSLog(@"bad message class!");
}
NSAttributedString *attribString = [[NSAttributedString alloc] initWithRTFD: messageData documentAttributes:nil];
}


The problem is that my documents are sometimes failing to reconstitute the NSAttributedString.
For any given document a load usually succeeds but on occasion fails with EXC_BAD_ACCESS.
The stack trace is:


#0 0x94f07688 in objc_msgSend
#1 0x9449f910 in processColor
#2 0x9449e95b in CharAttr
#3 0x94498b34 in -[NSRTFReader attributedString]
#4 0x94316c03 in _NSReadAttributedStringFromURLOrData
#5 0x94314943 in -[NSAttributedString(NSAttributedStringKitAdditions) initWithData:options:documentAttributes:error:]
#6 0x944fdde2 in -[NSAttributedString(NSAttributedStringKitAdditions) initWithRTFD:documentAttributes:]
#7 0x0000998c in -[UnitEntry(Private) updateMessageStringValue] at UnitEntry.m:406


This behaviour only seems to appear when the RTF data contains coloured text.
The random nature of this makes it feel like a memory allocation problem but the NSData object that fails to convert is in the moc.
Or maybe it's my random brain activity that is at fault, again.


The problem is more likely to appear the more objects are in the store.

Jonathan Mitchell

Central Conscious Unit
http://www.mugginsoft.com




_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: [MEET] Sydney (Australia) - CocoaHeads February 5th
  • Next by Date: Re: Setting data cell type for a specific row
  • Previous by thread: [MEET] Sydney (Australia) - CocoaHeads February 5th
  • Next by thread: A question about key equivalents for menu items
  • Index(es):
    • Date
    • Thread