• 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
Core data and NSTextView: get the attributed string?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Core data and NSTextView: get the attributed string?


  • Subject: Core data and NSTextView: get the attributed string?
  • From: Bernard Knaepen <email@hidden>
  • Date: Sun, 20 Jun 2010 15:11:50 +0200

Hello,

I have started playing with core data and I am having trouble to get the attributed string from an NSTextView into my program.

In the project, the .xcdatamodel contains an Entity called 'signatures' which has a property named 'sigText'. I have set the type of sigText to Binary Data.

In my .xib file, I have a NSScrollview containing an NSTextView. I have binded the NSTextView data to an object controller. The controller key is: selection; the model key path is 'sigText' and the value transformer is NSUnarchiveFromData.

The application correctly saves and displays my data when I save/open documents.

The trouble I have is to access the attributed string within my code to later draw in a custom view. I am trying something like this:

NSManagedObjectContext *context  = [self managedObjectContext];
NSManagedObjectModel   *model    = [self managedObjectModel];
NSDictionary           *entities = [model entitiesByName];
NSEntityDescription    *entity   = [entities valueForKey:@"signatures"];

NSFetchRequest * fetch = [[NSFetchRequest alloc] init];
[fetch setEntity: entity];

NSArray *results = [context executeFetchRequest:fetch error:nil];

myData = [[results objectAtIndex:0] valueForKey:@"sigText"];

NSAttributedString *signatureView = (NSAttributedString *)[NSUnarchiver unarchiveObjectWithData:myData];

[mypreview lockFocus];
[signatureView drawAtPoint:myPoint];
[mypreview unlockFocus];


Obviously something is wrong since the text is not drawn and the console outputs:

-[NSConcreteMutableData drawAtPoint:]: unrecognized selector sent to instance 0x114a3afb0

Any help with this would be very welcome!

Regards,

Bernard._______________________________________________

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

  • Follow-Ups:
    • Re: Core data and NSTextView: get the attributed string?
      • From: Michael Babin <email@hidden>
  • Prev by Date: scaling plot to nsview size
  • Next by Date: CoreData and memory leaks
  • Previous by thread: scaling plot to nsview size
  • Next by thread: Re: Core data and NSTextView: get the attributed string?
  • Index(es):
    • Date
    • Thread