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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:19:28+00:00 2026-05-26T06:19:28+00:00

singleton.h #import <Foundation/Foundation.h> @interface CrestronControllerValues : NSObject { NSString* ipAddress; NSString* portNumber; NSString* phoneAddress;

  • 0

singleton.h

#import <Foundation/Foundation.h>
@interface CrestronControllerValues : NSObject {
NSString* ipAddress;
NSString* portNumber;
NSString* phoneAddress;
NSString* cameleonVersion;
NSString* systemName;
NSString* iPID;
NSString* systemFeedBackName;
NSString* dJoinConnectedFB;
NSString* dJoinLow;
NSString* dJoinHigh;
NSString* aJoinLow;
NSString* aJoinHigh;
NSString* sJoinLow;
NSString* sJoinHigh;
NSMutableArray *currentPhonebookEntriesTelepresence;
NSMutableArray *currentPhonebookEntriesVideoChat;
NSMutableArray *currentPhonebookEntriesAudioChat;

}
@property (nonatomic, retain)    NSString* ipAddress;

@property (nonatomic, retain)    NSString* portNumber;

@property (nonatomic, retain)    NSString* phoneAddress;

@property (nonatomic, retain)    NSString* cameleonVersion;

@property (nonatomic, retain)     NSMutableArray *currentPhonebookEntriesTelepresence;

@property (nonatomic, retain)     NSMutableArray *currentPhonebookEntriesVideoChat;

@property (nonatomic, retain)     NSMutableArray *currentPhonebookEntriesAudioChat;

@property (nonatomic, retain)    NSString* systemName;

@property (nonatomic, retain)    NSString* iPID;

@property (nonatomic, retain)    NSString* systemFeedBackName;

@property (nonatomic, retain)    NSString* dJoinConnectedFB;

@property (nonatomic, retain)    NSString* dJoinLow;

@property (nonatomic, retain)    NSString* dJoinHigh;

@property (nonatomic, retain)    NSString* aJoinLow;

@property (nonatomic, retain)    NSString* aJoinHigh;

@property (nonatomic, retain)    NSString* sJoinLow;

@property (nonatomic, retain)    NSString* sJoinHigh;

+ (id)sharedManager;
    @end

i have my singleton.m:

        static CrestronControllerValues *sharedMyManager= nil;

    @implementation CrestronControllerValues
    @synthesize ipAddress, portNumber ,systemName, iPID, systemFeedBackName, dJoinConnectedFB, dJoinLow, dJoinHigh, aJoinLow, aJoinHigh, sJoinLow, sJoinHigh, cameleonVersion, currentPhonebookEntriesAudioChat, currentPhonebookEntriesTelepresence, currentPhonebookEntriesVideoChat, phoneAddress;


    +(CrestronControllerValues*)sharedManager
{
        @synchronized(self) {
    if(!sharedMyManager) {
        sharedMyManager = [CrestronControllerValues alloc];
        sharedMyManager = [sharedMyManager init];

    }
}
}

+(id)alloc
{
    @synchronized(self)
    {
        NSAssert(sharedMyManager == nil, @"Attempted to allocate a second instance of a singleton.");
        sharedMyManager = [super alloc];
        return sharedMyManager;
    }

    return nil;
}

    -(id)init {
        self = [super init];
        if (self != nil) {
            // initialize stuff here
        self.ipAddress = @"10.8.40.64";
self.portNumber = 41794;
self.systemName = @"";
self.iPID = 3;
self.cameleonVersion = nil;
self.currentPhonebookEntriesAudioChat = [[NSMutableArray alloc]initWithObjects:nil];  
self.currentPhonebookEntriesTelepresence = [[NSMutableArray alloc]initWithObjects:nil];
self.currentPhonebookEntriesVideoChat = [[NSMutableArray alloc]initWithObjects:nil];
self.phoneAddress = nil;
self.systemFeedBackName = @"";
self.dJoinConnectedFB = 5000;
self.dJoinLow = 1;
self.dJoinHigh = 1000;
self.aJoinLow = 1;
self.aJoinHigh = 1000;
self.sJoinLow = 1;
self.sJoinHigh = 1000;

        }
        return self; 
    }
        return self; 
    }

    -(void)setPhoneAddress:(NSString *)phoneaddress
    {
        @synchronized(self) {
            if (phoneAddress != phoneaddress) 
            {
                [phoneAddress release];
                phoneAddress = [phoneaddress retain];
            }
        }
    }
    -(NSString*)getPhoneAddress
    {
        return phoneAddress;
    }
    -(void)setCurrentPhonebookEntriesAudioChat:(NSMutableArray *)entries
    {
        @synchronized(self) {
            if (currentPhonebookEntriesAudioChat != entries) 
            {
                [currentPhonebookEntriesAudioChat release];
                currentPhonebookEntriesAudioChat = [entries retain];
            }
        }
    }
    -(NSMutableArray*)getCurrentPhonebookEntriesAudioChat
    {
        return currentPhonebookEntriesAudioChat;
    }
    -(void)setCurrentPhonebookEntriesTelepresence:(NSMutableArray *)entries
    {
        @synchronized(self) {
            if (currentPhonebookEntriesTelepresence != entries) 
            {
                [currentPhonebookEntriesTelepresence release];
                currentPhonebookEntriesTelepresence = [entries retain];
            }
        }
    }
    -(NSMutableArray*)getCurrentPhonebookEntriesTelepresence
    {
        return currentPhonebookEntriesTelepresence;
    }
    -(void)setCurrentPhonebookEntriesVideoChat:(NSMutableArray *)entries
    {
        @synchronized(self) {
            if (currentPhonebookEntriesVideoChat != entries) 
            {
                [currentPhonebookEntriesVideoChat release];
                currentPhonebookEntriesVideoChat = [entries retain];
            }
        }
    }
    -(NSMutableArray*)getCurrentPhonebookEntriesVideoChatLocal
    {
        return currentPhonebookEntriesVideoChat;
    }
    -(void)setCameleonVersion:(NSString *)cameleonversion
    {
        cameleonVersion = cameleonversion;
    }
    -(NSString*)getCameleonVersion
    {
        return cameleonVersion;
    }
    -(void)setIPaddress:(NSString *)ipaddress
    {
        ipAddress = ipaddress;
    }
    -(NSString*)getIPaddress
    {
        return ipAddress;
    }
    -(void)setPortNumber:(NSString *)portnumber
    {
        portNumber = portnumber;
    }
    -(NSString*)getPortNumber
    {
        return portNumber;
    }
    -(void)setSystemName:(NSString *)systemname
    {
        systemName = systemname;
    }
    -(NSString*)getSystemName
    {
        return systemName;
    }

    -(void)setIPID:(NSString *)ipid 
    {
        iPID=ipid;
    }
    -(NSString*)getIpid
    {
        return iPID;
    }

    -(void)setSystemFeedBackName:(NSString *)systemfeedbackname
    {
        systemFeedBackName=systemfeedbackname;
    }
    -(NSString*)getSystemFeedBackName
    {
        return systemFeedBackName;
    }

    -(void)setDJoinConnectedFB:(NSString *)djoinconnectedfb
    {
        dJoinConnectedFB = djoinconnectedfb;
    }
    -(NSString*)getDJoinConnectedFB
    {
        return dJoinConnectedFB;
    }

    -(void)setDJoinLow:(NSString *)djoinlow
    {
        dJoinLow=djoinlow;
    }
    -(NSString*)getDJoinLow
    {
        return dJoinLow;
    }

    -(void)setDJoinHigh:(NSString *)djoinhigh
    {
        dJoinHigh = djoinhigh;
    }
    -(NSString*)getDJoinHigh
    {
        return dJoinHigh;
    }

    -(void)setAJoinLow:(NSString *)ajoinlow
    {
        aJoinLow = ajoinlow;
    }
    -(NSString*)getAJoinLow
    {
        return aJoinLow;
    }

    -(void)setAJoinHigh:(NSString *)ajoinhigh
    {
        aJoinHigh = ajoinhigh;
    }
    -(NSString*)getAJoinHigh
    {
        return aJoinHigh;
    }

    -(void)setSJoinLow:(NSString *)sjoinlow
    {
        sJoinLow = sjoinlow;
    }
    -(NSString*)getSJoinLow
    {
        return sJoinLow;
    }

    -(void)setSJoinHigh:(NSString *)sjoinhigh
    {
        sJoinHigh = sjoinhigh;
    }
    -(NSString*)getSJoinHigh
    {
        return sJoinHigh;
    }

    - (void)dealloc
    {
        [self.ipAddress release];
        [self.iPID release];
        [self.portNumber release];
        [self.currentPhonebookEntriesVideoChat release];
        [self.currentPhonebookEntriesTelepresence release];
        [self.currentPhonebookEntriesAudioChat release];
        [self.aJoinHigh release];
        [self.aJoinLow release];
        [self.cameleonVersion release];
        [self.sJoinHigh release];
        [self.sJoinLow release];
        [self.dJoinHigh release];
        [self.dJoinLow release];
        [self.dJoinConnectedFB release];
        [super dealloc];
    }

    @end

and then i use it in 3 classes total
in one i set values:
if i read values from the CCV (sharedobject) i get the correct values. but this is in the same class as they are set from

CCV = [CrestronControllerValues sharedManager];
CCV.currentPhonebookEntriesAudioChat = currentPhonebookEntriesAudioChat;

and another i read the values:
(these show/read as nil)

switch (viewOptions) {
    case 1:
        [self setTableArray:CCV.currentPhonebookEntriesVideoChat];
        break;
    case 2:
        [self setTableArray:CCV.currentPhonebookEntriesVideoChat];
        break;
    case 3:
        [self setTableArray:CCV.currentPhonebookEntriesTelepresence];
        break;
    case 4:
        [self setTableArray:CCV.currentPhonebookEntriesAudioChat];
        break;
    default:
        [self setTableArray:CCV.currentPhonebookEntriesVideoChat];
        break;
}

but besides the class that i actually set the values in i do not get the filled array when i access it from another class
i have done NSLOG(@”%@”, CCV) and from what i can see all three classes have the same pointer so the shared instance seems to be working

  • 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-26T06:19:29+00:00Added an answer on May 26, 2026 at 6:19 am

    so in the end all i can do is apologize. none of you had the code that you would have needed to see what was going on.
    here is the array being saved (aboved was abridged (bad idea))

                if ([phonebookEntriesAudioChat count] >=8) {                
    
                    [CCV setCurrentPhonebookEntriesAudioChat:phonebookEntriesAudioChat];
                    [phonebookEntriesAudioChat removeAllObjects];
    
                }
    

    basically i was tring to add an item to the array from a socket return. getting one address up to 8 for each return/message. so i populated a temporary array (phonebookEntriesAudioChat) and added one to it for each message and once it got to 8 saved it to my singleton (CCV). but some how (and im still trying to figure this out) it would get to 8, be saved, temporary array cleared, then resaved the array (an empty one) to the singleton.

    thanks for all the help and direction, i know i dont get points for my own answer if one of you wants some easy points just re answer with a simliar description as this and ill give u the check. otherwise im just going to vote up ur comments and mark this as the answer in a day or two.

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

Sidebar

Related Questions

I have a a singleton class here is the code #import <Foundation/Foundation.h> #import CustomColor.h
Here's my singleton code (pretty much boilerplate): @interface DataManager : NSObject { NSMutableArray *eventList;
I'm using a Singleton class and following is the code: .h File: #import <Foundation/Foundation.h>
I met a problem when trying @Singleton of Guice: import com.google.inject.Singleton; @Singleton public class
Anyidea why autocomplete does not work on the spaceScene property? #import <Foundation/Foundation.h> #import cocos2d.h
I have created the following Singleton in my iPhone app: #import AppManager.h static AppManager
I have written a simple server - client program with Swing interface using singleton
I have such singleton class: package ua.org.bytes.ewt; import org.apache.struts2.ServletActionContext; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.WebApplicationContextUtils; import
Singleton, Decorator, Abstract, Factory, and the list goes on. How relevant are OO design
The singleton pattern is a design pattern that is used to restrict instantiation of

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.