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 7914047
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:59:21+00:00 2026-06-03T13:59:21+00:00

What I am doing is //ClassB.h @property (strong, nonatomic) NSString *name; and //ClassA.h @interface

  • 0

What I am doing is

    //ClassB.h
    @property (strong, nonatomic) NSString  *name;

and

 //ClassA.h
 @interface ClassA : NSObject
 +(ClassA*)methodA:(NSData*)data;
 -(id)initWithData:(NSData*)data;

    @property (nonatomic, strong) NSMutableArray *arr; 
    @property (nonatomic, strong) RXMLElement    *rxmlRoot; 

    @end

    //ClassA.m
    @implementation ClassA
    @synthesize arr;
    @synthesize rxmlRoot;

    +(ClassA*)methodA:(NSData*)data {
        return [[ClassA alloc] initWithData:data];
    }

    -(id)initWithData:(NSData*)data {
        self = [super init];
        if (self) {
            arr      = [NSMutableArray array];
            rxmlRoot = [RXMLElement elementFromXMLData:data];

             /*****edit : just been added to make codes clear*****/  
            NSString    *node   =   @"players.player";
            [rxmlRoot iterate:node with:^(RXMLElement *e){
                 ClassB   *classB  =   [[[ClassB alloc] init] autorelease];
                 [classB setName:       [e attribute:@"name"]];

                 // adding ClassB into arr
                 [arr addObject:classB];
            }];

        }
        return self;
    }
    @end

So now I am having ClassA object whose arr contains ClassB

Question : later on, when I try to access an particular property of ClassB like

((ClassB*)[classA.arr objectAtIndex:0]).name

and I am getting EXC_BAD_ACCESS at above line..

Please advice me on this issue and how to correct the error. Any comments are welcomed here

Thanks

  • 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-06-03T13:59:22+00:00Added an answer on June 3, 2026 at 1:59 pm

    This line

    [arr addObject:ClassB]
    

    makes no sense. Is your intention to put an instance of ClassB into that array, or the class itself (i.e. [ClassB class])? Presumably you must intend to put an instance of ClassB in there, otherwise trying to access its properties later on (e.g. firstName) would make no sense. Also, does your ClassB even have a firstName property, because the piece of ClassB’s interface that you show us only mentions a name property.

    Update:

    Since you are using manual memory management, you need to retain the objects (arr, rxmlRoot) you create in your initializer using convenience constructors, which return autoreleased objects. For example, the code should be

    arr = [[NSMutableArray array] retain];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider the following code: @interface ClassA : NSObject @property (nonatomic, copy) void(^blockCopy)(); @end @implementation
I'm not sure what I'm doing wrong. I'm thinking its because the NSMutableArray's *name
I'm doing an assignment for my Data Structures class. we were asked to to
I've created a data class name Person with an integer and a bool instance
I am doing the following class RuleObject implements Comparable{ @Override public String toString() {
What am I doing wrong here: class Helo { // main: generate some simple
I'm in an introductory comp-sci class (after doing web programming for years) and became
I know that one can define an 'expected' exception in JUnit, doing: @Test(expect=MyException.class) public
I need multemethod dispatch with Moose objects. I'm doing this with Class::Multimethods::Pure . I
In class we are doing sorting algorithms and, although I understand them fine when

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.