• 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: Triggering a Method when a Core Data Property is Altered.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Triggering a Method when a Core Data Property is Altered.


  • Subject: Re: Triggering a Method when a Core Data Property is Altered.
  • From: Joshua Garnham <email@hidden>
  • Date: Tue, 6 Oct 2009 23:32:51 -0700 (PDT)

Volker,


I have tried using the below code to add my self as an observer then trigger an action but it doesn't work.


- awakeFromNib {
[self addObserver: self
            forKeyPath: @"name"
               options: NSKeyValueObservingOptionNew
               context: NULL];
}

-(id)init {
        dispatch = [[NSDictionary dictionaryWithObjectsAndKeys:@selector(doSomething:),@"name", nil] retain];
}
...
- (void)observeValueForKeyPath:(NSString *)keyPath
            ofObject:(id)object
            change:(NSDictionary *)change
            context:(void *)context
{
    [self performSelector:msg withObject:object withObject:keyPath];
}

Is there something wrong that is blatantly obvious?

Cheers,
Josh.




________________________________
From: Volker in Lists <email@hidden>
To: Joshua Garnham <email@hidden>
Cc: email@hidden
Sent: Tuesday, 6 October, 2009 18:57:59
Subject: Re: Triggering a Method when a Core Data Property is Altered.

Josh,

depending on where you need to get a notification:

a) within the same NSManagedObject or a relationship: http://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Protocols/NSKeyValueObserving_Protocol/Reference/Reference.html#//apple_ref/occ/clm/NSObject/keyPathsForValuesAffectingValueForKey:

b) in any other object: just register as observer as described in KVO basics: http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/KeyValueObserving/Concepts/KVOBasics.html

Take note: The triggering happens not on the change of the TextFieldCell in a table, but due to a property changing.

When you have looked into KVO - what have you tried already?


Cheers,
Volker

Am 06.10.2009 um 18:45 schrieb Joshua Garnham:

> Hi.
>
> I am trying to trigger a method when A Core Data property is changed, e.g A Text Fields Text in a Table (connected to Core Data) is changed. I have looked into Key Value Observing but haven't had much luck.
>
> Cheers.
>
>
>
>
> _______________________________________________
>
> 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

Send instant messages to your online friends http://uk.messenger.yahoo.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

  • Follow-Ups:
    • Re: Triggering a Method when a Core Data Property is Altered.
      • From: Kyle Sluder <email@hidden>
  • Prev by Date: Re: app delegate +initialize
  • Next by Date: Re: Issues with NSWindowDelegate on multiple Mac OS X platforms
  • Previous by thread: Re: Triggering a Method when a Core Data Property is Altered.
  • Next by thread: Re: Triggering a Method when a Core Data Property is Altered.
  • Index(es):
    • Date
    • Thread