Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

alexskiing

macrumors newbie
Original poster
Oct 2, 2007
19
0
Hi, I have been playing around with the new Pubsub framework. I have been trying to get it to list everything in a feed. I have used the documentation for this, but it still wont work. If anyone has any experience with this pubsub framework please help! I have posted my code that I am trying to use below.

PSClient *client = [PSClient applicationClient];
NSURL *url = [NSURL URLWithString:
@"http://www.apple.com/main/rss/hotnews/hotnews.rss"];
PSFeed *feed = [client addFeedWithURL:url];
// 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);
// I get an error Here saying that "Title" is not right
NSLog(@"Entry Authors:%@", entry.authorsForDisplay);
// I get an error here
NSLog(@"Entry Content:%@", entry.content.plainTextString);
// AND I get an error here
}

// Then i try to download the attachment

// Get the enclosures from the current entry, and retrieve the first one
NSArray *enclosureArray = entry.enclosures;
enclosure = [enclosureArray objectAtIndex: 0];
NSError *error;

// Download the enclosure
if (![enclosure download:&error]) {
NSLog(@"Enclosure download failed: %@", error)
} else {

// Register for any changes to the download's state
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:mad:selector(downloadStateChanged:)
name: PSEnclosureDownloadStateDidChangeNotification
object: enclosure];
}
 
Post the specific error messages. And put your code in between [code] .. [/code] as it's much easier to read.
 
Ok

Code:
- (IBAction)rss:(id)sender {
PSClient *client = [PSClient applicationClient];
NSURL *url = [NSURL URLWithString:
@"http://www.apple.com/main/rss/hotnews/hotnews.rss"];
PSFeed *feed = [client addFeedWithURL:url];
// 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);
//error: request for member 'title' in something not a structure or union
NSLog(@"Entry Authors:%@", entry.authorsForDisplay);
//error: request for member 'Authors' in something not a structure or union
NSLog(@"Entry Content:%@", entry.content.plainTextString);
//error: request for member 'Content' in something not a structure or union
}
}
 
The errors are occurring because the compiler isn't recognizing your use of properties. Are you compiled against the 10.5 SDK or the 10.4?
 
Well I'm not sure. It worked for me in a new project. Make sure you're importing the headers correctly and have added the framework to the project.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.