Mac Developer Library

Developer

OpenDirectory Framework Reference ODQuery Class Reference

Options
Deployment Target:

On This Page
Language:

ODQuery

An ODQuery object serves as a Cocoa wrapper for an Open Directory query.

Inheritance


Conforms To


Import Statement


Swift

import OpenDirectory

Objective-C

@import OpenDirectory;

Availability


Available in OS X v10.6 and later.
  • Creates a query object with provided parameters.

    Declaration

    Swift

    init!(node inNode: ODNode!, forRecordTypes inRecordTypeOrList: AnyObject!, attribute inAttribute: String!, matchType inMatchType: ODMatchType, queryValues inQueryValueOrList: AnyObject!, returnAttributes inReturnAttributeOrList: AnyObject!, maximumResults inMaximumResults: Int, error outError: NSErrorPointer)

    Objective-C

    - (instancetype)initWithNode:(ODNode *)inNode forRecordTypes:(id)inRecordTypeOrList attribute:(ODAttributeType)inAttribute matchType:(ODMatchType)inMatchType queryValues:(id)inQueryValueOrList returnAttributes:(id)inReturnAttributeOrList maximumResults:(NSInteger)inMaximumResults error:(NSError **)outError

    Parameters

    inNode

    The node to query.

    inRecordTypeOrList

    The type or types of record to query. Can be an NSString object for a single type or an NSArray object containing NSString objects for multiple types.

    inAttribute

    The name of the attribute to query.

    inMatchType

    The type of query.

    inQueryValueOrList

    The value or values to query in the attribute. Can be an NSString object or an NSData object for a single value, or an NSArray containing NSString and NSData objects for multiple values.

    inReturnAttributeOrList

    The attribute or attributes to be returned from the query. Can be an NSString object for a single attribute or an NSArray object containing NSString objects for multiple attributes. Passing nil is equivalent to passing kODAttributeTypeStandardOnly.

    inMaximumResults

    The maximum number of values to return.

    outError

    An error reference for error details. Can be nil.

    Return Value

    The initialized query.

    Import Statement

    Objective-C

    @import OpenDirectory;

    Swift

    import OpenDirectory

    Availability

    Available in OS X v10.6 and later.

  • Returns an autoreleased query object created with provided parameters.

    Declaration

    Objective-C

    + (ODQuery *)queryWithNode:(ODNode *)inNode forRecordTypes:(id)inRecordTypeOrList attribute:(ODAttributeType)inAttribute matchType:(ODMatchType)inMatchType queryValues:(id)inQueryValueOrList returnAttributes:(id)inReturnAttributeOrList maximumResults:(NSInteger)inMaximumResults error:(NSError **)outError

    Parameters

    inNode

    The node to query.

    inRecordTypeOrList

    The type or types of record to query. Can be an NSString object for a single type or an NSArray object containing NSString objects for multiple types.

    inAttribute

    The name of the attribute to query.

    inMatchType

    The type of query.

    inQueryValueOrList

    The value or values to query in the attribute. Can be an NSString object or an NSData object for a single value, or an NSArray containing NSString and NSData objects for multiple values.

    inReturnAttributeOrList

    The attribute or attributes to be returned from the query. Can be an NSString object for a single attribute or an NSArray object containing NSString objects for multiple attributes. Passing nil is equivalent to passing kODAttributeTypeStandardOnly.

    inMaximumResults

    The maximum number of values to be returned.

    outError

    An error reference for error details. Can be nil.

    Return Value

    The initialized query.

    Import Statement

    Objective-C

    @import OpenDirectory;

    Availability

    Available in OS X v10.6 and later.

  • delegate delegate Property

    The query’s delegate.

    Declaration

    Swift

    unowned(unsafe) var delegate: ODQueryDelegate!

    Objective-C

    @property(nonatomic, readwrite, assign) id< ODQueryDelegate > delegate

    Import Statement

    Objective-C

    @import OpenDirectory;

    Swift

    import OpenDirectory

    Availability

    Available in OS X v10.6 and later.

  • The queue on which asynchronous results are delivered to the delegate.

    Declaration

    Swift

    var operationQueue: NSOperationQueue!

    Objective-C

    @property(readwrite, retain) NSOperationQueue *operationQueue

    Import Statement

    Objective-C

    @import OpenDirectory;

    Swift

    import OpenDirectory

    Availability

    Available in OS X v10.6 and later.

  • Retrieves results from a query asynchronously by scheduling the query in a run loop.

    Declaration

    Swift

    func scheduleInRunLoop(_ inRunLoop: NSRunLoop!, forMode inMode: String!)

    Objective-C

    - (void)scheduleInRunLoop:(NSRunLoop *)inRunLoop forMode:(NSString *)inMode

    Parameters

    inRunLoop

    The run loop.

    inMode

    The mode of the run loop.

    Discussion

    A delegate must be set prior to calling this method; otherwise, results may be lost due to the lack of a receiver.

    Import Statement

    Objective-C

    @import OpenDirectory;

    Swift

    import OpenDirectory

    Availability

    Available in OS X v10.6 and later.

  • Removes the query from a specified run loop.

    Declaration

    Swift

    func removeFromRunLoop(_ inRunLoop: NSRunLoop!, forMode inMode: String!)

    Objective-C

    - (void)removeFromRunLoop:(NSRunLoop *)inRunLoop forMode:(NSString *)inMode

    Parameters

    inRunLoop

    The run loop.

    inMode

    The mode to remove the query from.

    Import Statement

    Objective-C

    @import OpenDirectory;

    Swift

    import OpenDirectory

    Availability

    Available in OS X v10.6 and later.

  • Restarts a query, disposing of any results it has obtained.

    Declaration

    Swift

    func synchronize()

    Objective-C

    - (void)synchronize

    Discussion

    If the query was originally scheduled in a run loop with scheduleInRunLoop:forMode:, the delegate is called with inResults set to nil, [inError code] set to kODErrorQuerySynchronize, and [inError domain] set to kODErrorDomainFramework.

    Import Statement

    Objective-C

    @import OpenDirectory;

    Swift

    import OpenDirectory

    Availability

    Available in OS X v10.6 and later.

  • Returns results from a query synchronously.

    Declaration

    Swift

    func resultsAllowingPartial(_ inAllowPartialResults: Bool, error outError: NSErrorPointer) -> [AnyObject]!

    Objective-C

    - (NSArray *)resultsAllowingPartial:(BOOL)inAllowPartialResults error:(NSError **)outError

    Parameters

    inAllowPartialResults

    If YEStrue, only immediately available results are returned; otherwise, the function waits until all results are available.

    outError

    An error reference for error details. Can be nil.

    Return Value

    The results of the query in an array of ODRecord objects.

    Import Statement

    Objective-C

    @import OpenDirectory;

    Swift

    import OpenDirectory

    Availability

    Available in OS X v10.6 and later.