Help! Pubsub Framework

Discussion in 'Mac Programming' started by alexskiing, Dec 1, 2007.

  1. alexskiing macrumors newbie

    Joined:
    Oct 2, 2007
    #1
    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];
    }
     
  2. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #2
    Post the specific error messages. And put your code in between [code] .. [/code] as it's much easier to read.
     
  3. alexskiing thread starter macrumors newbie

    Joined:
    Oct 2, 2007
    #3
    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
    }
    }
     
  4. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #4
    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?
     
  5. alexskiing thread starter macrumors newbie

    Joined:
    Oct 2, 2007
  6. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #6
    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.
     

Share This Page