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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:00:30+00:00 2026-05-25T06:00:30+00:00

Right I have 5 views. One of the views is called RecordViewController. (RecordViewController is

  • 0

Right I have 5 views. One of the views is called RecordViewController. (RecordViewController is causing the error) I can switch through views fine. But once I get onto the recordviewcontroller, I can switch to another view. But if I want to switch back to recordviewcontroller. It throws me out of my app and gives me this error:

2011-08-27 19:52:00.358 app[1737:707] *** Assertion failure in +[RecordViewController alloc], /Users/user/Desktop/app/Classes/RecordViewController.m:111
2011-08-27 19:52:00.373 app[1737:707] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Attempted to allocated second singleton  RecordViewController'
*** Call stack at first throw:
(
    0   CoreFoundation                      0x36fd064f __exceptionPreprocess + 114
    1   libobjc.A.dylib                     0x34229c5d objc_exception_throw + 24
    2   CoreFoundation                      0x36fd0491 +[NSException raise:format:arguments:] + 68
    3   Foundation                          0x353d0573 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 62
    4   app                             0x00014bdd +[RecordViewController alloc] + 212
    5   app                             0x00013fd3 -[EffectsViewController goRecord:] + 34
    6   CoreFoundation                      0x36f40571 -[NSObject(NSObject) performSelector:withObject:withObject:] + 24
    7   UIKit                               0x35dd2ec9 -[UIApplication sendAction:to:from:forEvent:] + 84
    8   UIKit                               0x35dd2e69 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 32
    9   UIKit                               0x35dd2e3b -[UIControl sendAction:to:forEvent:] + 38
    10  UIKit                               0x35dd2b8d -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 356
    11  UIKit                               0x35dd283b -[UIControl touchesBegan:withEvent:] + 186
    12  UIKit                               0x35dd1bb1 -[UIWindow _sendTouchesForEvent:] + 300
    13  UIKit                               0x35dd156f -[UIWindow sendEvent:] + 262
    14  UIKit                               0x35dba313 -[UIApplication sendEvent:] + 298
    15  UIKit                               0x35db9c53 _UIApplicationHandleEvent + 5090
    16  GraphicsServices                    0x366f4e77 PurpleEventCallback + 666
    17  CoreFoundation                      0x36fa7a97 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 26
    18  CoreFoundation                      0x36fa983f __CFRunLoopDoSource1 + 166
    19  CoreFoundation                      0x36faa60d __CFRunLoopRun + 520
    20  CoreFoundation                      0x36f3aec3 CFRunLoopRunSpecific + 230
    21  CoreFoundation                      0x36f3adcb CFRunLoopRunInMode + 58
    22  GraphicsServices                    0x366f441f GSEventRunModal + 114
    23  GraphicsServices                    0x366f44cb GSEventRun + 62
    24  UIKit                               0x35de4d69 -[UIApplication _run] + 404
    25  UIKit                               0x35de2807 UIApplicationMain + 670
    26  app                                 0x00002e73 main + 70
    27  app                                 0x00002e28 start + 40
)
terminate called after throwing an instance of 'NSException'

Here is the code for recordviewcontroller

-(void)countUp {

    mainInt += 1;
    seconds.text = [NSString stringWithFormat:@"%02d", mainInt];

}

-(IBAction)goBack:(id)sender; {

    [self dismissModalViewControllerAnimated:YES];
}


static RecordViewController *sharedInstance = nil;


+(RecordViewController *) sharedInstance {
    @synchronized([RecordViewController class])
    {
        if (!sharedInstance)
        {
            [[self alloc]init];
        }
        return sharedInstance;
    }
    return nil;
}

+(id) alloc
{
    @synchronized([RecordViewController class])
    {
        NSAssert(sharedInstance == nil, @"Attempted to allocated second singleton  RecordViewController");
        sharedInstance = [super alloc];
        return sharedInstance;
    }
    return nil;
}


- (id)autorelease {
    return self;
}


- (void)viewDidLoad {
    [super viewDidLoad];


    toggle = YES;
    btnPlay.hidden = YES;


    AVAudioSession * audioSession = [AVAudioSession sharedInstance];

    [audioSession setCategory:AVAudioSessionCategoryPlayAndRecord error: &error];

    [audioSession setActive:YES error: &error];

}





- (IBAction)  start_button_pressed{


    if(toggle)
    {
        toggle = NO;
        [actSpinner startAnimating];
        [btnStart setImage:[UIImage imageNamed:@"recordstop.png"] forState:UIControlStateNormal];
        mainInt = 0;
        theTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(countUp) userInfo:nil repeats:YES];


        btnPlay.enabled = toggle;
        btnPlay.hidden = !toggle;


        NSMutableDictionary* recordSetting = [[NSMutableDictionary alloc] init];
        [recordSetting setValue :[NSNumber numberWithInt:kAudioFormatAppleIMA4] forKey:AVFormatIDKey];
        [recordSetting setValue:[NSNumber numberWithFloat:44100.0] forKey:AVSampleRateKey]; 
        [recordSetting setValue:[NSNumber numberWithInt: 2] forKey:AVNumberOfChannelsKey];


        recordedTmpFile = [NSURL fileURLWithPath:[NSTemporaryDirectory() stringByAppendingPathComponent: [NSString stringWithFormat: @"%.0f.%@", [NSDate timeIntervalSinceReferenceDate] * 1000.0, @"caf"]]];
        NSLog(@"Using File called: %@",recordedTmpFile);

        recorder = [[ AVAudioRecorder alloc] initWithURL:recordedTmpFile settings:recordSetting error:&error];

        [recorder setDelegate:self];

        [recorder prepareToRecord];

        [recorder record];


    }
    else
    {
        toggle = YES;
        [actSpinner stopAnimating];
        [btnStart setImage:[UIImage imageNamed:@"recordrecord.png"] forState:UIControlStateNormal];
        btnPlay.enabled = toggle;
        btnPlay.hidden = !toggle;
        [theTimer invalidate];

        NSLog(@"Using File called: %@",recordedTmpFile);

        [recorder stop];
    }
}

- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];

    // Release any cached data, images, etc that aren't in use.
}

-(IBAction) play_button_pressed{


    AVAudioPlayer * avPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:recordedTmpFile error:&error];
    [avPlayer prepareToPlay];
    [avPlayer play];

}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}

- (void)viewDidUnload {
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
    //Clean up the temp file.
    NSFileManager * fm = [NSFileManager defaultManager];
    [fm removeItemAtPath:[recordedTmpFile path] error:&error];
    //Call the dealloc on the remaining objects.
    [recorder dealloc];
    recorder = nil;
    recordedTmpFile = nil;
}

- (void)dealloc {
    [super dealloc];
}

@end

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-05-25T06:00:30+00:00Added an answer on May 25, 2026 at 6:00 am

    RecordViewController is declared as a singleton (Apple docs on Singletons). It would never really make sense to have a singleton view controller, but I’m going to ignore that and simply help you.

    The reason you are getting that exception is because you are calling [RecordViewController alloc] twice. It should only be called once because it is a singleton.

    To fix the problem you need to call [RecordViewController sharedInstance] every time you want to interact with the class, not [[RecordViewController alloc] init] like you might be accustomed to.

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

Sidebar

Related Questions

I hope I can explain this right I have two input fields that require
I have a page control and a scrollview implemented in one of my views.
I have a simple Coredata model with one entity called conversation and the other
I have a a class called ViewFactory and this class should deliver the right
I have a UITable View with a textfield that is editable right on the
I have this form in my view: <!-- Bug (extra 'i') right here-----------v -->
I have created a simple view consisting of 3 tables in SQL. By right
I actually have right now two questions: 1) What font faces are preferred for
So what I have right now is something like this: PropertyInfo[] info = obj.GetType().GetProperties(BindingFlags.Public);
This is what I have right now for a file residing on the same

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.