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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T23:21:04+00:00 2026-06-05T23:21:04+00:00

There is a strange behavior in my code and I really don’t know how

  • 0

There is a strange behavior in my code and I really don’t know how to solve it.
I have a Singleton class with this definition:

AppModelLocator.h>

#import <Foundation/Foundation.h>

@interface AppModelManager : NSObject

+ (AppModelManager *)sharedManager;

@end

AppModelLocator.m

#import "AppModelManager.h"

static AppModelManager *instance = nil;

@implementation AppModelManager

#pragma mark - Singletone
#pragma mark

+ (AppModelManager *)sharedManager
{
    @synchronized ([AppModelManager class]) {
        if (instance == nil) {
            instance = [AppModelManager new];
        }
    }

    return instance;
}

+ (id)alloc
{
    @synchronized ([AppModelManager class]) {
        NSAssert(instance == nil, @"Attempted to allocate the second instance of AppModelManager.");
        instance = [super alloc];
        return instance;
    }

    return nil;
}

@end

When I call [AppModelLocator sharedManager]somewhere in my code everything is fine. But when I call the singleton class after a specific line of code it throws me EXC_BAD_ACCESS (code=1, address=0xfffffeec) and refers to return instance in sharedManager definition in the singleton class.

That specific code is initializing a class that create a HTTP request and start sending the request but in the class is not any reference of AppModelLocator or something special. It is a simple creating of NSURLConnection and its delegate methods.

I used similar classes and approach in other applications and they are working fine and I wonder what is wrong with this class. I tried a dozen other ways of creating singleton class but none of them were useful.

  • 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-05T23:21:07+00:00Added an answer on June 5, 2026 at 11:21 pm

    Finally, I found what was wrong in the code. I made a NSURL instance dynamically and I used 3rd library to encrypt the URL. Something through the encoding caused the crash in special condition but I wonder why the exception raised after calling the singleton class. Anyway the issue was not because of the singleton definition as deanWombourne said.

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

Sidebar

Related Questions

I have come across a strange behavior with Microsoft Code Contracts that I don't
Is there any explanation of this strange behavior of defined constant? I have 1
I have this extremely strange behavior coming : In the below code: If I
There is probably a really simple answer for this ... I have a project
I have a very strange problem,I don't know whether it is awkward to normal
I have come to know that from IE 5, there is a strange behaviour
I have noticed that there are strange requests to my website trying to find
I promise you I am not lying. There is one strange line in this
I found out really strange behavior on relatively simple use case, probably I can't
I saw a strange behavior in a piece of code I wrote under Linux,

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.