PDA

View Full Version : Help! Pubsub Framework




alexskiing
Dec 1, 2007, 02:25 PM
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:@selector(downloadStateChanged:)
name: PSEnclosureDownloadStateDidChangeNotification
object: enclosure];
}



kainjow
Dec 1, 2007, 05:29 PM
Post the specific error messages. And put your code in between .. as it's much easier to read.

alexskiing
Dec 1, 2007, 08:33 PM
- (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
}
}

kainjow
Dec 1, 2007, 08:52 PM
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?

alexskiing
Dec 1, 2007, 10:52 PM
I am under the 10.5 SDK

kainjow
Dec 2, 2007, 01:01 PM
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.