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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:41:43+00:00 2026-06-14T11:41:43+00:00

If I use this custom getter: -(NSMutableArray *)queue { if (_queue == nil) {

  • 0

If I use this custom getter:

-(NSMutableArray *)queue
{
    if (_queue == nil)
    {
        if ([[NSFileManager defaultManager] fileExistsAtPath:kOfflineQueueFilePath]) {
            return [NSKeyedUnarchiver unarchiveObjectWithFile:kOfflineQueueFilePath];

            //[NSKeyedUnarchiver unarchiveObjectWithFile:kOfflineQueueFilePath];
        }else{
            return [[NSMutableArray alloc] init];
        }
    }
}

_queue is always (null). I don’t know why it happens.

But if I use the same code in init:

  if ([[NSFileManager defaultManager] fileExistsAtPath:kOfflineQueueFilePath]) {            
        sharedQueue.queue =  [NSKeyedUnarchiver unarchiveObjectWithFile:kOfflineQueueFilePath];
    }else{
        sharedQueue.queue = [[NSMutableArray alloc] init];
    }

It works like magic. Why am I doing it wrong?

  • 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-14T11:41:44+00:00Added an answer on June 14, 2026 at 11:41 am

    When you create a custom getter, you need to set the underlying ivar before returning the value.

    Change:

    if ([[NSFileManager defaultManager] fileExistsAtPath:kOfflineQueueFilePath]) {
        return [NSKeyedUnarchiver unarchiveObjectWithFile:kOfflineQueueFilePath];
    
        //[NSKeyedUnarchiver unarchiveObjectWithFile:kOfflineQueueFilePath];
    }else{
        return [[NSMutableArray alloc] init];
    }
    

    To:

    if ([[NSFileManager defaultManager] fileExistsAtPath:kOfflineQueueFilePath]) {
        _queue = [NSKeyedUnarchiver unarchiveObjectWithFile:kOfflineQueueFilePath];
    
        //[NSKeyedUnarchiver unarchiveObjectWithFile:kOfflineQueueFilePath];
    }else{
        _queue =  [[NSMutableArray alloc] init];
    }
    return _queue;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this custom textbox that I am working on and I can use
Is there a standard method I can use in place of this custom method?
I want to provide a custom Batcher for Hibernate to use (for this reason:
To use custom layout file in my app I'm using this following code, set
can i use custom attributes with linkbutton? like this: var linkb= new LinkButton(); linkb.ID
I'm trying to use translation in a custom twig filter like this public function
I'm trying to use the .Contains() function on a list of custom objects. This
Using Goggle Analytics I'd like to use a custom variable. This is built in
I have custom textfield widget and many form in my project. To use this
I'm kinda stuck trying to see why, when I use this custom UIView to

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.