mac-samples/PredicateEditorSample
Craig a6577adcdf sample metadata schema fix (remove tech) 2019-07-19 18:59:42 -07:00
..
Screenshots Added some screenshots 2012-12-11 17:39:08 -05:00
AppDelegate.cs Macsamples migrated to unified with tool 2014-11-21 20:09:57 -05:00
Info.plist Updated min deployment version (#113) 2018-11-15 03:52:17 -05:00
LICENSE.txt [PredicateEditorSample] Update license 2016-02-22 01:49:53 -03:00
Main.cs Macsamples migrated to unified with tool 2014-11-21 20:09:57 -05:00
MainMenu.xib Clean up sample 2010-12-05 21:11:06 -05:00
MainMenu.xib.designer.cs Macsamples migrated to unified with tool 2014-11-21 20:09:57 -05:00
Metadata.xml Add brief description tag to metadata.xml 2015-04-16 15:35:20 -04:00
MyWindow.cs Macsamples migrated to unified with tool 2014-11-21 20:09:57 -05:00
MyWindow.xib Clean up sample 2010-12-05 21:11:06 -05:00
MyWindow.xib.designer.cs Macsamples migrated to unified with tool 2014-11-21 20:09:57 -05:00
MyWindowController.cs [PredicateEditorSample] Fix build errors, bug #25450 2015-01-06 03:50:54 +03:00
PredicateEditorSample.csproj Set HttpClientHandler to NSUrlSessionHandler for all samples 2018-05-02 13:22:24 -06:00
PredicateEditorSample.sln Manually upgrade the solutions 2012-01-26 23:54:36 -05:00
README.md sample metadata schema fix (remove tech) 2019-07-19 18:59:42 -07:00

README.md

name description page_type languages products urlFragment
Xamarin.Mac - PredicateEditorSample PredicateEditorSample is a Xamarin.Mac sample application that shows how to use the NSPredicateEditor. The NSPredicateEditor class is a subclass of... sample
csharp
xamarin
predicateeditorsample

PredicateEditorSample

"PredicateEditorSample" is a Xamarin.Mac sample application that shows how to use the NSPredicateEditor.

The NSPredicateEditor class is a subclass of NSRuleEditor that is specialized for editing NSPredicate objects. This sample is intended to show how to use the many different features and aspects of this control and leverages Spotlight to search your Address Book.

It shows how to:

  • Manage this control inside your window along with an NSTableView.
  • Build Spotlight friendly queries based on NSPredicate and NSCompountPredicate.
  • Build search results based on NSMetadataQuery object.

Instructions

Simply build and run the sample using MonoDevelop with the Xamarin.Mac plugin. Enter query information pertaining to your Address Book. The application will display matches in its table view.

AddressBook searches are achieved by specifically requesting the "kind" of data to search via the kMDItemContentType key constant. This is the metadata attribute key that tells Spotlight to search for address book data only. Together along with the other predicates from the NSPredicateEditor class we form a "compound predicate" and start the query. The code snippet below found in this sample shows how this is done:

// always search for items in the Address Book
NSPredicate addrBookPredicate = NSPredicate.FromFormat("(kMDItemContentType == 'com.apple.addressbook.person')",new NSObject[0]);
predicate = NSCompoundPredicate.CreateAndPredicate(new NSPredicate[2] {addrBookPredicate, predicate});

// set the query predicate....
query.Predicate = predicate;

// and send it off for processing...
query.StartQuery();

Xamarin port changes are released under the MIT license

PredicateEditorSample application screenshot

Author

Ported to Xamarin.Mac by Kenneth J. Pouncey.