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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:02:12+00:00 2026-05-20T10:02:12+00:00

I’m reading in an XML file from an XMLReader class, which I create and

  • 0

I’m reading in an XML file from an “XMLReader” class, which I create and call from the app delegate. Inside the XMLReader class, I’m creating an “AppState” object which contains the data read in the XML. The XMLReader autoreleases the AppState class when it creates it. When the XMLReader is done, the app delegate assigns the the AppState instance to its own variable, retains it, and releases the XMLReader class. The code in the app delegate looks like this:

XMLReader *xmlReader = [[XMLReader alloc] init];

[xmlReader parseXMLData: data];

appState = xmlReader.appState; // <== xmmReader creates appState with autorelease

[appState retain];

[xmlReader release];

I’m a bit unclear as to whether there is a convention that you shouldn’t need to retain assigned objects within the class to which the object is assigned. In this case it’s required due to the autorelease – if I don’t retain it in the app delegate, the app crashes. Is there a better way? e.g. I could create the AppState in the delegate and set it on XML reader. That way the alloc and release could be in the same class. What’s the typical way to do this?

  • 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-20T10:02:13+00:00Added an answer on May 20, 2026 at 10:02 am

    There is a better way – simply create a (retain) @property for your appState object, synthesize it and assign your xmlReader.appState to self.appState instead.

    This is retain the new value and assign it to your appState object.

    You can then release it/set it to nil in the App delegate’s dealloc method.

    @interface XXX : AppDelegate
    {
    }
    @property (nonatomic, retain) XXXXX appState
    

    And implement

    @implementation XXX
    @synthesize appState;
    

    Then assign with

    self.appState = xmlReader.appState;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my XML file chapters tag has more chapter tag.i need to display chapters
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I have a text area in my form which accepts all possible characters from
I'm parsing an XML file, the creators of it stuck in a bunch social
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I used javascript for loading a picture on my website depending on which small
Basically, what I'm trying to create is a page of div tags, each has

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.