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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T16:15:17+00:00 2026-06-04T16:15:17+00:00

I am newbie on ios programming, so I have a question. I am working

  • 0

I am newbie on ios programming, so I have a question. I am working on an app, will continue to load data on internet, it’s paging data, so when the user navigate to the next page, it will load the data of the page on the internet. I use a singleton class to make it, it works fine, but I had a question –

When the first page is arrival I save it to self.posts variable like – self.posts = dataA, and when the user go for the next page, it will change self.posts to dataB, like self.posts = dataB. my question is, if the dataA will be released by iOS automatically, or it’s not? if it’s not, how to deal with these garbage memory? You know it will load data page by page, if so many pages being loaded, it might be a problem……Thanks.

Sorry forget to tell you guys, the app is for iOS 3.x+, so I guess ARC is not available. Check this function, it will be called after the HTTP connection is done and will parse JSON to NSDictionary, each time it will load about 5 posts for a page, and next page is another 5 posts, so you know, the self.posts changed if it’s another new HTTP networking.

- (void) getNextPostsFromJson:(NSData *)data
{
    NSError *theError = nil;

    NSDictionary *dict = [[CJSONDeserializer deserializer] deserializeAsDictionary:data error:&theError];

    if (dict == nil) {
        isValidJson = NO;
        httpStatus = HTTP_STATUS_FAILED;

        NSLog(@"json con - %@ %@",
              [theError localizedDescription],
              [[theError userInfo] objectForKey:NSURLErrorFailingURLStringErrorKey]);   
    } else {

        NSArray *keys = [dict allKeys];        

        if ([keys count] >= TOTAL_SECTIONS) {
            self.posts = dict;
        } else {
            self.posts = nil;
        }

        NSLog(@"posts = %@", self.posts);
        return;
    }
}
  • 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-04T16:15:18+00:00Added an answer on June 4, 2026 at 4:15 pm

    Toaster suggestion is right.

    If you use a property like the following.

    @property (nonatomic, retain) NSDictionary* posts;
    

    when you do

    self.posts = dataB;
    

    the old value referenced object is released for you.

    The setter synthesized by the compiler using @synthesize directive looks like this (pseudo code here):

    - (void)setPosts:(NSDictionary*)newPosts
    {
        if(newDict != posts) {
    
            [newPosts retain]; // retain the new value
            [posts release]; // release the old value
            posts = newPosts; // now posts reference the new value
        }
    }
    

    A simple suggestion for you.

    If you do self.posts = dataB you lose dataA. So when you came back, you need to perform the download again. So, what do you think to have a cache of downloaded data? For example create a NSMutableDictionary where each key is the page (the number of the page or whatever you like) and each value is the data (dataA, dataB and so on). Through it, you can avoid to download data each time. Maybe you can also set up a limit for this cache (say 5 data) to prevent memory issues.

    Hope it helps.

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

Sidebar

Related Questions

I'm a newbie to iOS programming, I have a project and my requirements are
I'm newbie in iOS development and I have a question. I have a some
Standard newbie question. I've created a data model for an iOS application. I am
I am newbie working on iOS application for iPad. I have successfully implemented a
iOS newbie question here. I have a UITabBarController as my root controller with a
I am an absolute newbie at ios programming so forgive me: I have a
I am a complete newbie to iOS development but not to programming. I am
I'm a newbie at iOS development and this is my first question on SO.
This may sound a newbie question however I'm new to iOS dev. Are there
Newbie question... The objective: I intend to have an HTML text input field as

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.