A client can subscribe to multiple feeds, but not all feeds are updated at the same interval. You may have one feed that needs to be checked every five minutes, while another feed only needs to be updated every three hours. Similarly, you may want the time it takes an entry to expire to depend on the feed. The feed settings objects allow you to customize the preferences for each feed. Each feed object is instantiated with a group of default settings.
To customize the preferences for a feed, obtain a feed settings object by either using the settings property of a feed object, or the PSFeedSettings defaultFeedSettings class method. Then adjust the settings as you see fit with the different properties. Store the updated feed settings in the feed object.
Listing 3-4 retrieves the settings object, sets the entries to expire after 30 days, sets the feed to update every 30 minutes, and then puts the settings object back in the feed.
Listing 3-4 Modifying the settings of a feed
// Retrieve PSFeedSettings object from feed |
PSFeedSettings *feedSettings = feed.settings; |
// Set entries to expire after 30 days (60 s/m * 60m/h * 24 h/d * 30 d) |
feedSettings.expirationInterval = 2592000; |
// Set feed to check for updates every 30 minutes (60 s/m * 30m) |
feedSettings.refreshInterval = 1800; |
// Store settings back in the feed |
feed.settings = feedSettings; |
You can also set the feed settings for a client. If you do, a feed that uses the default settings inherits the client’s settings instead of the default ones. However, any settings unique to a feed overrides the settings of the client.
You now know how to create a feed object for any web feed and adjust the preferences for them. The next chapter, “Viewing and Retrieving Content,” explains how to obtain the entries and other information in the feed.
Last updated: 2007-05-11