Apple Developer Connection
Member Login Log In | Not a Member? Contact ADC

< Previous PageNext Page > Hide TOC

Where’s My Entry?

Most feeds contains one or more entries. To retrieve the entries from a feed object, use either the entries property (for an array of entry objects) or the entryEnumeratorSortedBy: method (for an enumerator of entry objects).

An entry object contains all the information specific to an entry, such as its title, its URL, its authors, its content, and, if necessary, its enclosures. Most of this information is a simple string or URL. However, three of components are a little more complicated.

In some feed standards, the author contains not only a name but also contains an email address and a homepage (see “Feed Formats”). The author information in Publication Subscription is stored in an author object. An author object represents a name, an email address, a homepage and a link to an ABPerson object.

The content of an entry is also more complex than a simple string. It often comes in one of two different forms: either plain text, or HTML formatted text. In Publication Subscription the content and the summary of an entry are stored as content objects. A content object contains methods for retrieving the content either as a plain text string or an HTML string. The content is returned in the specified format based on which accessor method is used.

An enclosure is a way to attach a file to an entry. If an entry contains enclosures, they will be linked to the entry object. For more information about enclosures, read “Downloading Enclosures.”

To print out the title and content of every entry in a feed, the code would look like Listing 4-1.

Listing 4-1  Accessing every entry in a feed

// Retrieve the entries as an unsorted enumerator
NSEnumerator *entries = [feed entryEnumeratorSortedBy: nil];
PSEntry *entry;
 
// Go through each entry and print out the title, authors, and content
while (entry = [entries nextObject]) {
    NSLog(@"Entry Title:%@", entry.title);
    NSLog(@"Entry Authors:%@", entry.authorsForDisplay);
    NSLog(@"Entry Content:%@", entry.content.plainTextString);
}

Since it follows an observer design pattern, Publication Subscription can also notify your application when any changes occur to a feed. Register with the notification center to be alerted when any change occurs (PSFeedEntriesChangedNotification). When your callback method is invoked, the changed entries are stored as a key-value pair in the user information dictionary of the notification.



< Previous PageNext Page > Hide TOC


Last updated: 2007-05-11




Did this document help you?
Yes: Tell us what works for you.

It’s good, but: Report typos, inaccuracies, and so forth.

It wasn’t helpful: Tell us what would have helped.
Get information on Apple products.
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Copyright © 2007 Apple Inc.
All rights reserved. | Terms of use | Privacy Notice