开发者

Program suddenly has many bugs [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 11 years ago.

I have been building a program for the past few months. I finally got to the point where everything was working great. The program has been built for iOS 5 from the beginning. And i just checked on things that i thought i had cemented in and that were working fine when i checked a few days ago. But now everything is acting goofy. My recorder stopped working. Not sure in what area. My seeker's values arnt changing as they should. Playback of the recording is not working. The recorder used to take a second to load up where it would freeze the screen then start, now it is instantaneous which i find odd. Im sorry if im being vague but im totally stumped. The record button sets off a timer after the record command. In the timer there is an if statement, which has many clauses, one being myRecorder.isRecording == NO, and yet the if statement acts as if the conditions are met and executes the code inside, despite the recorder being told to record right before the timer even started. I AM BAFFLED. Please help. Thanks

Code for record button: - (IBAction)record:(id)sender { //[myPlayer play];

if ([sender tag] == 2){
    [self stop];
    [sender setTag:1];
    [sender setTitle:@"Record"];
    [sender setEnabled:NO];
    NSLog(@"Tag is 2");
}else{
    if ([myPlayer isPlaying]){
        [myPlayer pause];
        [myPlayer setCurrentTime:0];
    }
    anotherControl = 0; 
    theToolbar.userInteractionEnabled = NO;
    [theToolbar setTintColor:myColor];
    [theToolbar setAlpha:.5];
    [controlSong setTintColor:[UIColor blackColor]];
    beatPackTable.userInteractionEnabled = NO;
    beatPackTable.hidden = YES;
    onScreenTut.text = @"(Hold phone to your face and begin. When finished recording, hit the stop button)";
    recordCover.titleLabel.text = @"Recording";
    recordCover.titleLabel.textAlignment = UITextAlignmentCenter;
    recordCover.hidden = NO;
    NSString *docsDir;
    myDate = [[NSDate alloc] init];
    myDate = [NSDate date];
    seekerTwo.userInteractionEnabled = NO;
    homeButton.enabled = NO;
    tracksButton.enabled = NO;
    tutButton.enabled = NO;
    previewBeatTwo.enabled = NO;
    previewPauseTwo.enabled = NO;

    /*    
     NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
     [dateFormatter setTimeStyle:NSDateFormatterShortStyle];
     [dateFormatter setDateStyle:NSDateFormatterShortStyle];
     NSString *myDate2 = [NSString stringWithFormat:@"%@",[dateFormatter stringFromDate:myDate]];
     */    
    //    dirPaths = NSSearchPathForDirectoriesInDomains(
    //                                                   NSDocumentDirectory, NSUserDomainMask, YES);
    docsDir = NSTemporaryDirectory();


    NSString *soundFilePath = [docsDir
                               stringByAppendingPathComponent:[NSString stringWithFormat:@"%@%i.caf",myDate,control]];

    NSURL *soundFileURL = [NSURL fileURLWithPath:soundFilePath];

    NSDictionary *recordSettings = [NSDictionary 
                                    dictionaryWithObjectsAndKeys:
                                    [NSNumber numberWithInt:AVAudioQualityLow],
                                    AVEncoderAudioQualityKey,
                                    [NSNumber numberWithInt:16], 
                                    AVEncoderBitRateKey,
                                    [NSNumber numberWithInt: 2], 
                                    AVNumberOfChannelsKey,
                                    [NSNumber numberWithFloat:44100.0], 
                                    AVSampleRateKey,
                                    nil];

    NSError *error = nil;



    myNewRecorder = [[AVAudioRecorder alloc]
                  initWithURL:soundFileURL
                  settings:recordSettings
                  error:&error];

    if (error)
    {
        NSLog(@"error: %@", [error localizedDescription]);

    } else {
        [myNewRecorder prepareToRecord];}




    seeker.userInteractionEnabled = NO;
    voiceVolumeControl.enabled =YES;
    recordButton.enabled = NO;

    stopButton.enabled = YES;


    myPlayer.currentTime = 0;
    [myNewRecorder record];
    [myPlayer play];
    [NSTimer scheduledTimerWithTimeInterval:1.0f
 开发者_开发百科                                    target:self
                                   selector:@selector(updateCounter:)
                                   userInfo:nil
                                    repeats:YES];

if ([sender tag] == 1){
    [sender setTitle:@"End"];
    [sender setTag:2];

}}
NSLog(@"%@",myDate);
}

Code for timer:

-(void)updateCounter:(NSTimer *)theTimer{

    if ([myNewRecorder isRecording]) {
        [seeker setValue:myPlayer.currentTime/myPlayer.duration animated:YES];}

    if ([myPlayer2 isPlaying])
    {
        [seeker setValue:myPlayer2.currentTime/myPlayer2.duration animated:YES];
    }

    if ([myPlayer isPlaying] && myPlayer2.isPlaying == NO && myNewRecorder.isRecording == NO && isNotepadOpen == NO && anotherControl == 0) {
        [myPlayer stop];
        myPlayer.currentTime = 0;
        [seeker setValue:0];
        playButton.enabled = YES;
        stopButton.enabled = NO;
        NSLog(@"Its the timer for some reason");
    }

    if ([myNewRecorder isRecording] || [myPlayer isPlaying] || [myPlayer2 isPlaying]){
        [[UIApplication sharedApplication] setIdleTimerDisabled:YES];
    }else{
        [[UIApplication sharedApplication] setIdleTimerDisabled:NO];
    }
    if ([myPlayer isPlaying]){
        [seekerTwo setValue:myPlayer.currentTime/myPlayer.duration animated:YES];
    }
}


See my answer (and others) to that question on Programmers SE: “It was working yesterday, I swear!” What can you do?

Basically, find what has changed since the sudden bugs, maybe a new delivery of iOS 5, Xcode or an external library that your software uses.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜