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

Re: Core data and NSTextView: get the attributed string?


  • Subject: Re: Core data and NSTextView: get the attributed string?
  • From: Michael Babin <email@hidden>
  • Date: Mon, 21 Jun 2010 14:35:40 -0500

On Jun 20, 2010, at 8:11 AM, Bernard Knaepen wrote:

> 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

From the error message, it would appear signatureView is not an NSAttributedString (NSMutableData, instead). So work backwards. You're making assumptions in your code: valueForKey:@"sigText" returns an NSData object, using NSUnarchiver on it yields an NSAttributedString. Test them (step through in debugger, NSLog(), etc) and see if your assumptions are valid. If they aren't valid, then move back up the chain to where the value is stored and see if you're storing the correct data. If your assumptions are valid, then I would suspect there might be some intervening code and you may be running into object ownership issues (retain/release, zombies).


_______________________________________________

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: Bernard Knaepen <email@hidden>
References: 
 >Core data and NSTextView: get the attributed string? (From: Bernard Knaepen <email@hidden>)

  • Prev by Date: Re: docs, KVO and NSUserDefaults etc.
  • Next by Date: Re: Async NSURLConnection and blocks (was: Running NSURLConnection from within an NSOperation?)
  • Previous by thread: Core data and NSTextView: get the attributed string?
  • Next by thread: Re: Core data and NSTextView: get the attributed string?
  • Index(es):
    • Date
    • Thread