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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:15:36+00:00 2026-06-13T04:15:36+00:00

I have a singleton in application and need to call its function with arguements

  • 0

I have a singleton in application and need to call its function with arguements from another class, but when I call it, nil arguements are passed…here is the code:

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    NSLog([Singleton sharedMySingleton].test);
    NSDictionary *story = [self.filters objectAtIndex: indexPath.row];

    MainAppRecord *record = [[[MainAppRecord alloc]init]retain];
    record.name = [story objectForKey:@"Name"];
    record.searchUrl = [story objectForKey:@"SearchUrl"];
    record.icon = [imageCash objectForKey:indexPath];
    [[Singleton sharedMySingleton] changeMainFilterTo:record atPosition:indexOfFilterToChange];

}

Here is Singleton.h and its function:

@interface Singleton : NSObject {

    NSMutableArray *mainFilters;
    NSString *test;
}

@property (nonatomic, retain) NSMutableArray *mainFilters;
@property (nonatomic, retain) MainAppRecord *filterToChange;

-(void) initWithPlist;
-(void) saveToPlist;
-(void)changeMainFilterTo:(MainAppRecord*)record atPosition:(int)position;
+(Singleton *)sharedMySingleton;

@end



-(void)changeMainFilterTo:(MainAppRecord*)record atPosition:(int)position 
{
    [mainFilters insertObject:record atIndex:position];
}

The app crashes with

2012-10-20 16:24:52.789 TableView[1957:207] -[__NSArrayI insertObject:atIndex:]: unrecognized selector sent to instance 0x68410f0

Thanks

  • 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-13T04:15:38+00:00Added an answer on June 13, 2026 at 4:15 am

    This is nothing to do with arguments not being passed, or singletons.

    You’ve declared an NSMutableArray property in your singleton, but it looks like you’ve assigned an NSArray to it. You don’t show where you set this up but it looks like you’re loading it from a property list – this creates a immutable array by default. You then try to insert an object – which up can’t do to an immutable array.

    Ensure that when you create the array, you are creating a mutable array.

    The simplest way to do this is to find the code where you are currently assigning the array, and make a mutable copy instead:

    self.mainFilters = [[NSKeyedUnarchiver unarchiveObjectWithData:other] mutableCopy];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Assume I have a singleton class in an external lib to my application. But
I have an application using TTS very heavily. It's working fine, but I need
If we have a singleton class like LoadBalancer and need one instance per ASP.NET
I have a c++ application. I need to load some config data from file.
I'm building a web-application using JSF/Primefaces. I need to have a constants-class, i.e. a
I have a situation where I need to call a method1() in class B
I have a Singleton to manage some variables I need in various places in
I have a singleton class for global access to config information. This singleton class
I have a Singleton that is accessed in my class via a static property
I have a singleton object that use another object (not singleton), to require some

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.