Mac Developer Library

Developer

PSClient Class Reference

Options
Deployment Target:

On This Page
Language:

PSClient

A PSClient object represents a client of the API that has its own set of feeds. PSClient is the backbone of the Publication Subscription framework. To subscribe to feeds, your application must use a client object. You can then add feeds to the PubSub Database with the addFeed: and addFeedWithURL: methods. Similarly, you can unsubscribe from a feed with the removeFeed: method. It is not recommended that you subclass PSClient.

  • Subscribes the client to the given feed.

    Declaration

    - (BOOL) addFeed: (PSFeed*)feed;

    Parameters

    feed

    The existing feed object to subscribe to.

    Return Value

    YEStrue on success; NOfalse if an immediate error occurred.

    Discussion

    A feed object may only belong to one client, so if the given feed has already been added to any other client, this method will fail. Instead, create a new feed object with the same URL as the existing one or use addFeedWithURL:.

  • Subscribes the client to the feed at the given URL.

    Declaration

    - (PSFeed *) addFeedWithURL: (NSURL*)url;

    Parameters

    url

    The URL of the feed. Must be an HTTP, HTTPS, or FEED protocol.

    Return Value

    The subscribed feed, or nil if an error occurred.

    Discussion

    This method creates a subscribed feed from the given URL. If a feed with this URL is already subscribed, this method returns a feed object from the existing data in the PubSub Database.

  • Returns the entry with the given identifier.

    Declaration

    - (PSEntry *) entryWithIdentifier: (NSString*)identifier;

    Parameters

    identifier

    The unique string associated with a entry.

    Return Value

    The entry associated with the specified identifier, or nil if the identifier is not in a subscribed feed.

    Discussion

    Entry identifiers are persistent, unique, and unchangeable, so they provide a way for your application to establish a persistent reference to an entry. This method considers only entries in feeds subscribed to by this client.

  • Returns the feed with the specified identifier.

    Declaration

    - (PSFeed *) feedWithIdentifier: (NSString*)identifier;

    Parameters

    identifier

    The unique string associated with a feed.

    Return Value

    The feed associated with the specified identifier, or nil if the client isn't subscribed to the feed associated with this identifier.

    Discussion

    Feed identifiers are persistent, unique, and unchangeable, so they provide a way for your application to establish a persistent reference to an feed. This method considers only feeds subscribed to by this client.

  • Returns the subscribed feed with the given URL.

    Declaration

    - (PSFeed *) feedWithURL: (NSURL*)url;

    Parameters

    url

    The URL of the feed.

    Return Value

    The feed from the given URL.

  • Unsubscribes the client from a feed.

    Declaration

    - (BOOL) removeFeed:(PSFeed *)feed;

    Parameters

    feed

    The feed to be removed.

    Return Value

    YEStrue if the client is unsubscribed; NOfalse if an error occurred.

  • Calls the delegate methods and sends the corresponding notifications that would have been called if the client had been running since the specified date.

    Declaration

    - (void) sendChangesSinceDate:(NSDate *)dateLastUpdated;

    Parameters

    dateLastUpdated

    The date after which you want changes sent.

    Discussion

    Some clients may choose to associate their data with various Publication Subscription instances. Since feeds and articles can change when a client isn't running, dateLastUpdated and sendChangesSinceDate: are needed to maintain a synchronized state. The typical date passed to this method is the value that was returned by the dateLastUpdated method just before the application quit.

  • Returns a list of the bundle identifiers for the clients that have registered with the PubSub Agent.

    Declaration

    + (NSArray*) allClientBundleIdentifiers;

    Return Value

    An array of string objects containing the bundle identifiers of the clients registered with the PubSub Agent.

    Discussion

    This method should be used by applications that want to inspect the subscriptions of another application or construct a set of all subscribed feeds. However, the results may not be complete, because this method does not return the bundle identifiers of private clients.

  • Creates the default instance for the current application.

    Declaration

    + (PSClient*) applicationClient;

    Return Value

    A client object for the current application.

  • Creates a client for the specified bundle identifier.

    Declaration

    + (PSClient*) clientForBundleIdentifier:(NSString *)bundleIdentifier;

    Parameters

    bundleIdentifier

    The bundle identifier of the client you want to inspect.

    Return Value

    A client object for the specified bundle identifier.

    Discussion

    This method should be used by applications that want to inspect the subscriptions of other applications or by a suite of applications that want to use a shared subscription client. If you need to create a client for the current application, use applicationClient instead.

  • signature Property

    The application bundle identifier associated with the PSClient instance.

    Declaration

    @property (readonly, retain) NSString * signature;

  • settings Property

    The feed settings of the client.

    Declaration

    @property (retain) PSFeedSettings * settings;

    Discussion

    If the settings have not been modified, returns the default settings.

    This property attempts to communicate with the PubSubAgent process and causes the agent to launch if it is not already running. If PubSubAgent cannot be contacted, an exception will be thrown with the name PSException. To avoid problems, you should always be prepared to catch an exception thrown by this property.

  • isPrivate Property

    A Boolean value that indicates whether the client instance is private.

    Declaration

    @property (getter=isPrivate, setter=setPrivate:) BOOL isPrivate;

    Discussion

    A private PSClient instance can be accessed only by an application process whose bundle identifier matches the signature of the PSClient.

  • feeds Property

    An array of all the feeds subscribed to by the client.

    Declaration

    @property (readonly) NSArray * feeds;

    Discussion

    The ordering of the feeds in the array is undefined.

  • delegate Property

    The delegate of the client.

    Declaration

    @property (assign) id delegate;

    Discussion

    The delegate should implement the PSClientDelegate informal protocol.

  • The date and time associated with the most recent feed-change notification delivered to the receiver's delegate.

    Declaration

    @property (readonly) NSDate * dateLastUpdated;

    Discussion

    If no notifications have been sent at the time this method was called, it returns the date and time that the receiver was created. Because feeds and entries can change when a client isn't running, store the value from dateLastUpdated when your application quits, and pass that value to sendChangesSinceDate: to retrieve any notifications that would have been called while your application was not running.