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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T15:03:38+00:00 2026-06-03T15:03:38+00:00

This is the original codes when I am getting this error ClassA.h +(ClassA*)methodA:(NSData*)data; @property

  • 0

This is the original codes when I am getting this error

ClassA.h

+(ClassA*)methodA:(NSData*)data;

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

@end

ClassA.m

+(ClassA*)methodA:(NSData*)data {

//NSLog(@"class is %@",[name class]);
ClassA *ClassA   =   [[Stores alloc] init];
arr        =   [NSMutableArray array];
rxmlRoot   = [RXMLElement elementFromXMLData:data];

}

I am reviewing my codes and now I have tow options to fix the code

OptionA

ClassA.h

+(ClassA*)methodA:(NSData*)data;

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

@end

ClassA.m

+(ClassA*)methodA:(NSData*)data {

//NSLog(@"class is %@",[name class]);
ClassA *ClassA   =   [[Stores alloc] init];
ClassA.arr        =   [NSMutableArray array];             <----- this has been modified
ClassA.rxmlRoot   = [RXMLElement elementFromXMLData:data];<----- this has been modified

}

OptionB

ClassA.h

+(ClassA*)methodA:(NSData*)data;

@end

ClassA.m

static RXMLElement    *rxlRoot; <----- this has been added as class variable
static NSMutableArray *arr;     <----- this has been added as class variable

+(ClassA*)methodA:(NSData*)data {

//NSLog(@"class is %@",[name class]);
ClassA *ClassA   =   [[Stores alloc] init];
arr        =   [NSMutableArray array];             
rxmlRoot   = [RXMLElement elementFromXMLData:data];

}

I try either optionA or optionB and the compiler does not complain anything and the codes work properly.

I see many posts following the optionB which create class variables.

Question: is optionA also a good way to follow when we are dealing with class method and class variable as well.

Please advice me on this issue and by the way if I have made mistakes somewhere, please correct me. 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-03T15:03:39+00:00Added an answer on June 3, 2026 at 3:03 pm

    Create a designated initializer with a data parameter. Every class should have a designated initializer.

    In your class method call the designated initializer passing in data.

    Here is example code:

    //ClassA.h
    @class RXMLElement;
    
    @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];
        }
        return self;
    }
    @end
    

    ARC is assumed in the example.

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

Sidebar

Related Questions

I am getting this error and I have no idea what it means: $
from this code will show in original color how can i change it to
String product = Integer.toString(w); char[] original = String.toCharArray(product); This is the code I have
This is a continuation of this question: Original Question (SO) The answer to this
I'm curious why is method fillInStackTrace of java.lang.Throwable public? This method replaces original stack
This is a slightly original variation on a common problem. I have a fairly
this is an edit of the original post now that I better understand the
Original SQL query is this; SELECT id,post_title,post_date FROM wp_posts where id='1' When I retrieve
This is what my .htaccess file looks like: # Original # If you modify
This question is sort of a follow-up to my original question here . Let's

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.