• 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 commit changes made programmatically
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Core data commit changes made programmatically


  • Subject: Re: Core data commit changes made programmatically
  • From: Kyle Sluder <email@hidden>
  • Date: Wed, 24 Apr 2013 20:08:13 +0200

Mutating an attributed string doesn't count as "key-value coding", even if the string itself is exposed as a KVC-compliant property.

Since the only KVC-compliant change for the textStorage property would be to change it to a completely new object instance, and that would be very wasteful, you will need to add another property that you mutate in a KVC-compliant manner to trick Core Data into noticing your attributed string has changed.

--Kyle Sluder

On Apr 23, 2013, at 11:41 PM, Peng Gu <email@hidden> wrote:

> I have a textview that is binding to Core data, I want to be able to
> highlight the selected text in the textview.
>
> *[self.textStorage addAttribute:NSBackgroundColorAttributeName value:[
> NSColor yellowColor] range:self.selectedRange];*
>
> The code above works, but core data won't save the attributes changes
> unless I type some words in the Textview. Calling moc to commit editting
> doesn't save the changes too.
>
> *[aManagedObjectContext commitEditing];*
>
> *[aManagedObjectContext save:&error];*
>
> I also tried to set the value of the object in Core data after adding the
> attributes, but *[aManagedObject setValue:text forKey:@"text"] *will make
> the textview lose focus.
>
>
> Is there any way to force the core data to save the changes immediately? Or
> any better way to highlight selected text in NSTextview, like addFontTrait:
> used by Bold, Italic Menu Items?
>
>
> Thanks,
>
> - Peng
>
> *
> *
> _______________________________________________
>
> 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

_______________________________________________

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 commit changes made programmatically
      • From: Peng Gu <email@hidden>
References: 
 >Core data commit changes made programmatically (From: Peng Gu <email@hidden>)

  • Prev by Date: Re: Temporarily disabling autosave
  • Next by Date: Re: Temporarily disabling autosave
  • Previous by thread: Re: Core data commit changes made programmatically
  • Next by thread: Re: Core data commit changes made programmatically
  • Index(es):
    • Date
    • Thread