• 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
NSPredicate / NSArray addObserver:forKeyPath:options:context: exception
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSPredicate / NSArray addObserver:forKeyPath:options:context: exception


  • Subject: NSPredicate / NSArray addObserver:forKeyPath:options:context: exception
  • From: Mikkel Eide Eriksen <email@hidden>
  • Date: Thu, 27 Sep 2012 19:54:27 +0200

Hi all,

I have some objects in an array and I want to filter it in the UI off my app.

I first created a test case to test out various NSPredicates, and have verified that they work. For instance, filtering an array with the following predicate yields correct results:

[NSPredicate predicateWithFormat:@"ANY personalNames.value.gedcomString CONTAINS %@", @"Hansen"]

I then set about implementing an NSPredicateEditor and have put in the following NSPredicateRowTemplate:

    [[NSPredicateEditorRowTemplate alloc] initWithLeftExpressions:stringExpressions
                                     rightExpressionAttributeType:NSStringAttributeType
                                                         modifier:NSAnyPredicateModifier
                                                        operators:stringOperators
                                                          options:0]

Where stringExpressions is an array containing:

[NSExpression expressionForKeyPath:@"personalNames.value.gedcomString"]

When I run my app, I get an exception (quoted below) as soon as I expose my objects to my array controller (via a property on my document it's bound to), though as far as I can tell, the predicate should be functionally the exact same? For completness, inspecting it in the debugger yields:

(NSPredicate *) $0 = 0x000000010f87d790 ANY personalNames.value.gedcomString CONTAINS ""

I've verified that the array <__NSArrayM 0x109cfb490> contains the expected personalNames from the first object in the array I'm filtering.

Can anyone provide some insights here?

Regards,
Mikkel Eide Eriksen

> 2012-09-27 19:08:18.261 GedcomGUI[29311:9e0b] An uncaught exception was raised
> 2012-09-27 19:08:18.261 GedcomGUI[29311:9e0b] [<__NSArrayM 0x109cfb490> addObserver:forKeyPath:options:context:] is not supported. Key path: value.gedcomString
> 2012-09-27 19:08:18.263 GedcomGUI[29311:9e0b] (
> 	0   CoreFoundation                      0x00007fff8fdb9716 __exceptionPreprocess + 198
> 	1   libobjc.A.dylib                     0x00007fff99b49470 objc_exception_throw + 43
> 	2   CoreFoundation                      0x00007fff8fdb94ec +[NSException raise:format:] + 204
> 	3   Foundation                          0x00007fff955c04b7 -[NSArray(NSKeyValueObserverRegistration) addObserver:forKeyPath:options:context:] + 76
> 	4   Foundation                          0x00007fff955204ae -[NSKeyValueNestedProperty object:didAddObservance:recurse:] + 226
> 	5   Foundation                          0x00007fff955191b9 -[NSObject(NSKeyValueObserverRegistration) _addObserver:forProperty:options:context:] + 222
> 	6   Foundation                          0x00007fff9551812d -[NSObject(NSKeyValueObserverRegistration) addObserver:forKeyPath:options:context:] + 111
> 	7   AppKit                              0x00007fff9809864a -[_NSModelObservingTracker _registerOrUnregister:observerNotificationsForModelObject:] + 200
> 	8   AppKit                              0x00007fff980981dd -[_NSModelObservingTracker startObservingModelObjectsAtReferenceIndexes:] + 364
> 	9   AppKit                              0x00007fff9805bd74 -[NSArrayController _arrangeObjectsWithSelectedObjects:avoidsEmptySelection:operationsMask:useBasis:] + 717
> 	10  AppKit                              0x00007fff98075d8e -[NSArrayController setContent:] + 878
> 	11  AppKit                              0x00007fff98075568 -[NSArrayDetailBinder _refreshDetailContentInBackground:] + 1268
> 	12  Foundation                          0x00007fff95521a90 NSKeyValueNotifyObserver + 390
> 	13  Foundation                          0x00007fff955234a9 NSKeyValueDidChange + 456
> 	14  Foundation                          0x00007fff954dea0f -[NSObject(NSKeyValueObserverNotification) didChangeValueForKey:] + 130
> 	15  GedcomGUI                           0x0000000100001d66 -[Document context:didFinishWithEntityCount:] + 550
> 	16  Gedcom                              0x000000010004df67 -[GCContext parseNodes:error:] + 3383
> 	17  Gedcom                              0x000000010004e770 -[GCContext parseData:error:] + 832
> 	18  GedcomGUI                           0x000000010000155e __22-[Document parseData:]_block_invoke_0 + 78
> 	19  libdispatch.dylib                   0x00007fff8f645f3d _dispatch_call_block_and_release + 15
> 	20  libdispatch.dylib                   0x00007fff8f6420fa _dispatch_client_callout + 8
> 	21  libdispatch.dylib                   0x00007fff8f64323e _dispatch_worker_thread2 + 304
> 	22  libsystem_c.dylib                   0x00007fff92b13ceb _pthread_wqthread + 404
> 	23  libsystem_c.dylib                   0x00007fff92afe1b1 start_wqthread + 13
> )

_______________________________________________

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: NSPredicate / NSArray addObserver:forKeyPath:options:context: exception
      • From: Willeke <email@hidden>
    • Re: NSPredicate / NSArray addObserver:forKeyPath:options:context: exception
      • From: Willeke <email@hidden>
    • Re: NSPredicate / NSArray addObserver:forKeyPath:options:context: exception
      • From: Willeke <email@hidden>
  • Prev by Date: Re: splitting CJK text into "words"
  • Next by Date: interpretKeyEvents: and insertText: under 10.8
  • Previous by thread: Re: splitting CJK text into "words"
  • Next by thread: Re: NSPredicate / NSArray addObserver:forKeyPath:options:context: exception
  • Index(es):
    • Date
    • Thread