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 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

dear all, i'll take some data from the database. and join two tables.the code
dear all, i need to combine two different result in one script. The problem
Possible Duplicate: LINQ Between Operator Dear All, Hi, I need to write this query
dear all,this is my code at xampp: $sql = INSERT INTO oqc_defect ; $sql.=
dear all..i have some data at DB. name Range bla 123x9901-123x0000 //it means range
Dear all, how do I get to peek at the source code for any
Dear All, I am trying to achieve svn copy operation with the help of
Dear all, i want to show some data in one row from 1 column
Dear g++ hackers, I have the following question. When some data of an object
Dear all,I am now using a webtool http://fiddesktop.cs.northwestern.edu/mmp/scrape?url= to parse a webpage. For example,we

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.