Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1077711
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T21:36:57+00:00 2026-05-16T21:36:57+00:00

I use an NSXMLParser to parse YouTube’s API and I get all the content

  • 0

I use an NSXMLParser to parse YouTube’s API and I get all the content I want and put it into a class called Video. When I am writing to the class from inside parserDidEndElement and I end that video I write the class to an NSMutableArray. Then I NSLog the title of the video that was logged into the array. This is different for each video. I use the addObject: method to add videos to the array. However when I use parserDidEndDocument I use a for loop to read through the array and all of the entries have the same title value of the last object added! What is going on here?

I call this in didEndElement:

Video *tempVideo = [Video new];
NSString *title = @"";
tempVideo = [allVideos objectAtIndex:[allVideos count]-1];
title = tempVideo.videoTitle;
NSLog(@"1videoTitle = %@", title);

It returns for each element 1videoTitle = (the videos title)

I call this in didEndDocument:

int i;
Video *tempVideo = [Video new];
NSString *title = @"";
for(i=0;i<[allVideos count];i++){
    tempVideo = [allVideos objectAtIndex:i];
    title = tempVideo.videoTitle;
    NSLog(@"videoTitle = %@", title);
}

It returns for each element videoTitle = (the last added videos title for all 19 of the videos)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T21:36:58+00:00Added an answer on May 16, 2026 at 9:36 pm

    tc’s answer is correct, but let me re-phrase.

    You are missing a very basic detail of Objective-C.

    Video *tempVideo = [Video new];
    tempVideo = [allVideos objectAtIndex:[allVideos count]-1];
    

    The first line declares a variable tempVideo that is a pointer to an instance of the Video class and assigns to it a reference to a freshly allocated instance of Video class.

    The second line re-assigns tempVideo to be a reference to an object from the allVideos array. It is not a copy of the object, but a reference to the same object in the array. The first instance — the one from [Video new] — is effectively leaked.

    What isn’t shown is where and how you add the Video objects to the array.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 523k
  • Answers 523k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer If your target is 3.2 or higher, you can use… May 16, 2026 at 9:37 pm
  • Editorial Team
    Editorial Team added an answer The Windows binaries generally work for every mini release for… May 16, 2026 at 9:37 pm
  • Editorial Team
    Editorial Team added an answer A named instance does not listen on port 1433, only… May 16, 2026 at 9:37 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I'm learning to use the NSXMLParser API for the iOS platform and so far
I just ran into this one and couldn't seem to get any clear answer
My objective is to abort the NSXMLParser when I parse an item that already
I am using a NSXMLParser class in my program and I assign a delegate
I've loaded an XML file as NSData into memory and parse over the elements
I have a xml file. That I want to parse with NXXMLParser. I have
I was wondering how do I use the NSXML parser. so lets say given
I am new to iphone development.I am able to parse a Xml file at
I've been wondering if there's a way to parse XML in Objective C as
I want to save user generated data in an XML file in the iphone.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.