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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T02:55:40+00:00 2026-05-18T02:55:40+00:00

Dear all. I need to keep some temporary information in code. When i access

  • 0

Dear all.
I need to keep some temporary information in code. When i access to it, i make instant copy of my class, receive result as MutableArray, but i have to using this array in other method’s of code.
I don’t like to make instant copy of my class again, bcs this take memory and processor time, but i have to using rest of array in other methods.
Currently i keep it in array controller, but i like to find other better way.
In some reasons i don’t like to send pointer to this MutableArray as method’s parameter.
ProjectArrays.h:

#import <Cocoa/Cocoa.h>
@interface ProjectArrays : NSObject {
NSMutableArray *myMutableArray;    
}
@property (nonatomic, retain) NSMutableArray *myMutableArray;
+(ProjectArrays *)sharedProjectArrays;

@end

ProjectArrays.m:

#import "ProjectArrays.h"
#import "SynthesizeSingleton.h"

@implementation ProjectArrays

SYNTHESIZE_SINGLETON_FOR_CLASS(ProjectArrays)

@synthesize myMutableArray;

- (void)dealloc {
// Clean-up code here.
[myMutableArray release];
[super dealloc];
}

@end

AppDelegate.m:

[[ProjectArrays sharedProjectArrays].myMutableArray addObject:@"Test"];

NSLog (@"This is test first point:%@",[[ProjectArrays sharedProjectArrays].myMutableArray objectAtIndex:0]);

2010-11-21 19:26:18.636 snow[14523:a0f] This is test first point:(null)

looks like code can’t care objects.

  • 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-18T02:55:41+00:00Added an answer on May 18, 2026 at 2:55 am

    Try using singleton pattern. Create some singleton class and keep there environmental variables.

    Here is useful header file: http://snipplr.com/view/32737/synthesizesingleton-definition-header/

    It will help you to create singletons promptly.

    EDITED:

    Here is a singleton you’d like to use

    //YourSingletonClassName.h
    #import <Foundation/Foundation.h>
    
    
    @interface YourSingletonClassName : NSObject {
      NSMutableArray *myMutableArray;
    }
    
    @property (nonatomic, retain)   NSMutableArray *myMutableArray;
    
    + (YourSingletonClassName *)sharedYourSingletonClassName;
    
    @end
    
    
    //YourSingletonClassName.m
    #import "YourSingletonClassName.h"
    #import "SynthesizeSingleton.h"
    
    @implementation YourSingletonClassName
    
    SYNTHESIZE_SINGLETON_FOR_CLASS(YourSingletonClassName)
    
    @synthesize myMutableArray;
    
    - (id) init
    {
      self = [super init];
      if (self != nil) {
         self.myMutableArray = [NSMutableArray new];
      }
      return self;
    }
    
    
    - (void) dealloc {
      [myMutableArray release];
      [super dealloc];
    }
    
    @end
    

    You can call YourSingletonClassName anywhere by [YourSingletonClassName sharedYourSingletonClassName];, you shouldn’t alloc/init it, e.g:

    [[YourSingletonClassName sharedYourSingletonClassName].myMutableArray addObject:@"some_object_to_add"];
    

    Please google for singleton pattern and dig through obj c conceptions.

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

Sidebar

Related Questions

Possible Duplicate: LINQ Between Operator Dear All, Hi, I need to write this query
Dear all,I am now using a webtool http://fiddesktop.cs.northwestern.edu/mmp/scrape?url= to parse a webpage. For example,we
Dear all, I now have a preliminary macro (defmacro key-if(test &key then else) `(cond
Dear all,Now i have this question in my java program,I think it should be
I need to ask a simple question to anyone. Any clue will be much
Dear members of the Stackoverflow community, We are developing a web application using the
I have requirement where I need to allow users to upload a Word document
i have one text box formated with follwoing syntax $(#cont_dt).blur(function(){ $(this).format({format:#,###.00, locale:us}); }) this
Duplicate Managing date formats differences between PHP and MySQL PHP/MySQL: Convert from YYYY-MM-DD to
I am not so proficient in TSql as of now (writing since last 4/5

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.