Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 322717
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T08:57:53+00:00 2026-05-12T08:57:53+00:00

I can create an NSPredicate easily using an NSPredicateEditor (a subclass of NSRuleEditor). What

  • 0

I can create an NSPredicate easily using an NSPredicateEditor (a subclass of NSRuleEditor). What I’d like to know is this:

How can I take an existing NSPredicate (one created by the editor) and reload it into the editor so that I can alter it?

EDIT: I tried @John’s suggestion of using setObjectValue:, but that didn’t quite work. Let me explain my set up a bit more:

I’ve got a Document-based cocoa app, and the Document window just has an NSPredicateEditor on it. In the dataOfType:error: method, I have:

NSPredicate * pred = [predicateEditor objectValue];
NSData * predicateData = [NSKeyedArchiver archivedDataWithRootObject:pred];
return predicateData;

In the readFromData:ofType:error: method, I have:

NSPredicate * pred = [NSKeyedUnarchiver unarchiveObjectWithData:data];
[predicateEditor setObjectValue:pred];
return (pred != nil);

I’ve verified that the predicate is getting correctly archived and unarchived, but after opening a saved predicate, the predicate is not loaded into the predicateEditor. (Yes, predicateEditor is hooked up as an IBOutlet)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T08:57:53+00:00Added an answer on May 12, 2026 at 8:57 am

    Set the objectValue property of the NSPredicateEditor to the predicate in question.

    The documentation has this description of the loading process; does any of this seem like it might cause a problem with your setup?

    First, an instance of
    NSPredicateEditor is created, and some
    row templates are set on it—either
    through a nib file or
    programmatically. The first thing
    predicate editor does is ask each of
    the templates for their views, using
    templateViews.

    After setting up the predicate editor,
    you typically send it a
    setObjectValue: message to restore a
    saved predicate. NSPredicateEditor
    needs to determine which of its
    templates should display each
    predicate in the predicate tree. It
    does this by sending each of its row
    templates a matchForPredicate: message
    and choosing the one that returns the
    highest value.

    After finding the best match for a
    predicate, NSPredicateEditor copies
    that template to get fresh views,
    inserts them into the proper row, and
    then sets the predicate on the
    template using setPredicate:. Within
    that method, the
    NSPredicateEditorRowTemplate object
    must set its views’ values to
    represent that predicate.

    NSPredicateEditorRowTemplate next asks
    the template for the “displayable
    sub-predicates” of the predicate by
    sending a
    displayableSubpredicatesOfPredicate:
    message. If a template represents a
    predicate in its entirety, or if the
    predicate has no subpredicates, it can
    return nil for this. Otherwise, it
    should return a list of predicates to
    be made into sub-rows of that
    template’s row. The whole process
    repeats for each sub-predicate.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I can create p as a pointer to f like this: f: func[][print 1]
I can create a new object like this: Dim sqlconn As New SqlClient.SqlConnection(cs) or
I can create a stack class quite easily, using push and pop accessor methods
I can create a confirm box in Ext JS like this: with this code:
I can create database manually by going to cpanel. But I'd like to create
One can create an anonymous object that is initialized through constructor parameters, such as
I can create a sparse php array (or map) using the command: $myarray =
i would like to know how to fetch all events from an EventStore using
I can create a faceted plot like so, with 3 plots stacked vertically :
I can create UIImage from NSData using [UIImage imageWithData:] or [UIImage initWithData:] methods. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.