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

  • Home
  • SEARCH
  • 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 782263
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T20:21:34+00:00 2026-05-14T20:21:34+00:00

I have 3 classes-> video { nameVideo, id, description, user… } topic {nameTopic, topicID,

  • 0

I have 3 classes->

video { nameVideo, id, description, user... }  
topic {nameTopic, topicID, NSMutableArray videos; }  
category {nameCategory, categoryID, NSMUtableArray topics}  

And then in my app delegate I defined-> NSMutableArray categories;

I parse an XML file with this code. I try the arrays hierachy, and i think that i don’t add any object on the arrays. How can I check it? What’s wrong?

- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName
  namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName
    attributes:(NSDictionary *)attributeDict {

    if([elementName isEqualToString:@"Videos"]) {
        //Initialize the array.
        appDelegate.categories = [[NSMutableArray alloc] init];
    }


    else if ([elementName isEqualToString:@"Category"])
    {
        aCategory = [[Category alloc] init];

        aCategory.categoryID = [[attributeDict objectForKey:@"id"] integerValue];

        NSLog(@"Reading id category value: %i", aCategory.categoryID);

    }

    else if ([elementName isEqualToString:@"Topic"]) {
        aTopic = [[Topic alloc] init];

        aTopic.topicID = [[attributeDict objectForKey:@"id"] integerValue];

        NSLog(@"Reading id topic value: %i", aTopic.topicID);

    }

    else if ([elementName isEqualToString:@"video"]) {

        aVideo = [[Video alloc] init];

        aVideo.videoID = [[attributeDict objectForKey:@"id"] integerValue];
        aVideo.nameTopic = currentNameTopic; 
        aVideo.nameCategory = currentNameCategory; 

        NSLog(@"Reading id video value: %i", aVideo.videoID);

    }


    NSLog(@"Processing Element: %@", elementName);
}



- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string {

    if(!currentElementValue)
        currentElementValue = [[NSMutableString alloc] initWithString:string];
    else
        [currentElementValue appendString:string];

    NSLog(@"Processing Value: %@", currentElementValue);

}

- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName
  namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName {

    if([elementName isEqualToString:@"Videos"]) 
        return; 

    if ([elementName isEqualToString:@"Category"]) {
        [appDelegate.categories addObject:aCategory];
         [aCategory release];
         aCategory = nil;
    }


    if ([elementName isEqualToString:@"Topic"]) {
        [aCategory.topics addObject:aTopic];
        //NSLog(@"contador: %i", [aCategory.topics count]);
        //NSLog(@"contador: %@", aTopic.nameTopic);

        [aTopic release];
        aTopic = nil;
    }        

    if ([elementName isEqualToString:@"video"]) {
        [aTopic.videos addObject:aVideo];
        NSLog(@"count number videos:  %i", [aTopic.videos count]); --> always 0
        NSLog(@"NOM CATEGORIA VIDEO:  %@", aVideo.urlVideo); --> OK

        [aVideo release];
        aVideo = nil;
    }

    if ([elementName isEqualToString:@"nameCategory"]) {
        //[aCategory setValue:currentElementValue forKey:elementName];
        aCategory.nameCategory = currentElementValue; 
        currentNameCategory = currentElementValue; 
    }

    if ([elementName isEqualToString:@"nameTopic"]) {
        aTopic.nameTopic = currentElementValue; 
        currentNameTopic = currentElementValue; 
    }


    else 
    [aVideo setValue:currentElementValue forKey:elementName];

    [currentElementValue release];
    currentElementValue = nil;

}

//xmlparser.h

@class TSCTerrassaAppDelegate, Category, Topic, Video; 
@interface XMLParser : NSObject {

    NSMutableString *currentElementValue; 
    NSMutableString *currentNameCategory;
    NSMutableString *currentNameTopic; 

    TSCTerrassaAppDelegate *appDelegate; 

    Video *aVideo;
    Topic *aTopic; 
    Category *aCategory; 
}

@property (nonatomic, retain)NSMutableString *currentNameCategory; 
@property (nonatomic, retain) NSMutableString *currentNameTopic;

//Video.h

@interface Video : NSObject {

    NSInteger videoID; 
    NSString *nameVideo;
    NSString *nameCategory; 
    NSString *nameTopic; 
    NSString *user;
    NSString *date; 
    NSString *description; 
    NSString *urlThumbnail;
    NSString *urlVideo;
}

//Topic.h

@class Video; 

@interface Topic : NSObject {
    NSMutableString *nameTopic; 
    NSInteger topicID; 
    NSMutableArray *videos; 
}

@property (nonatomic, readwrite) NSInteger topicID;
@property (nonatomic, retain) NSMutableArray *videos; 
@property (nonatomic, retain) NSMutableString *nameTopic; 

//Category.h

@class Topic, Video; 

@interface Category : NSObject {
    NSMutableString *nameCategory; 
    NSInteger categoryID; 
    NSMutableArray *topics; 
}

@property (nonatomic, retain) NSMutableArray *topics;
@property (nonatomic, readwrite) NSInteger categoryID; 
@property (nonatomic, retain) NSMutableString *nameCategory;

//AppDelegate

@class NavegaNavController;

@interface TSCTerrassaAppDelegate : NSObject <UIApplicationDelegate> {
    UIWindow *window;
    IBOutlet UITabBarController *rootController; 
    IBOutlet NavegaNavController *navegaNavController; 

    NSMutableArray *categories; 
}

@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet UITabBarController *rootController; 
@property (nonatomic, retain) IBOutlet NavegaNavController *navegaNavController; 

@property (nonatomic, retain) NSMutableArray *categories; 

And here is a short sample of XML file:

<Videos>
<Category id="12"> 
<nameCategory>xxxx</nameCategory>
<Topic id="43"> 
<nameTopic>zzzz</nameTopic> 
<video id="54"> 
<nameVideo>videoest1</nameVideo> 
<user>skiria</user> 
<date>24-11-09</date>
<description>testing videos</description> 
<urlThumbnail>URLTHUMBNAIL</urlThumbnail> <urlVideo>http://bipbop/gear1/prog_index.m3u</urlVideo>
</video>
</Topic>
</Category>
</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-14T20:21:35+00:00Added an answer on May 14, 2026 at 8:21 pm

    It doesn’t look like aTopic.videos is ever alloc’d/init’d.

    Right after you create aTopic in didStartElement, do alloc+init on aTopic.videos.

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

Sidebar

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.