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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T14:38:49+00:00 2026-05-31T14:38:49+00:00

I have little problem in my iPhone application code but can not identify. please

  • 0

I have little problem in my iPhone application code but can not identify. please help.

bellow is my code gives me error.

this code is in loop.

- (void)playSoundSequence{     
if(songCounter >= totalSoundsInQueue || songCounter < 0){
    songCounter = 0;
}
NSLog(@"%d", songCounter);
sound = [[NSString alloc] initWithFormat:@"%@", [theSoundArray objectAtIndex:songCounter]];
NSLog(@"call");
audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:sound ofType:@""]] error:NULL];
sound =  nil;
[sound release];
audioPlayer.delegate = self;
audioPlayer.volume = m_volSlider.value;
[audioPlayer play];
m_progressBar.progress = 0;
m_progressSlider.value = 0;
m_progressSlider.maximumValue = audioPlayer.duration;
[m_btnPlay setBackgroundImage:[UIImage imageNamed:@"pause.png"] forState:UIControlStateNormal];
bgTaskId = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:NULL];
timer = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(updateDisplay) userInfo:nil repeats:YES];
songCounter++;
}

songCounter is integer and one by one increment according to loop.

In this code theSoundArray is my array that contain like bellow

"song1.mp3",
"song2.mp3",
"song3.mp3",
"song4.mp3" 

The problem is whenever first time my loop was called and “songCounter” was 0 it’s run fine. Then 2nd time goes in loop and “songCounter” was 1 then there have problem and gives me error.

Below is the error.

-[__NSCFString objectAtIndex:]: unrecognized selector sent to instance
  • 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-31T14:38:50+00:00Added an answer on May 31, 2026 at 2:38 pm

    I hope you have not retained the array , and so when you are accessing that after some time, it crashes.

    So, do as following while initializing the theSoundArray. See the retain

    NSString *bundleRoot = [[NSBundle mainBundle] bundlePath]; 
    NSFileManager *fm = [NSFileManager defaultManager]; 
    NSArray *dirContents = [fm contentsOfDirectoryAtPath:bundleRoot error:nil]; 
    NSPredicate *fltr = [NSPredicate predicateWithFormat:@"self ENDSWITH '.mp3'"]; 
    theSoundArray = [[dirContents filteredArrayUsingPredicate:fltr] retain];
    

    And try now.

    EDIT

    And the order is not correct in the following statements.

    sound =  nil;
    [sound release];
    

    You release it and then set it to nil.

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

Sidebar

Related Questions

I have little problem with my iphone application. I have such classes and interfaces:
I have a little problem with a Listview. I can load it with listview
I have a little problem about using jQuery (I really do not know jQuery
I have a little problem. I had some JComboBox to a JDialog but they
I have a little problem. I have to upload a photo from my iPhone
I'm having problem with my application on iPhone 3GS. I've created a little game,
I have little knowledge with the iPhone SKD (don't even know what code it
I am a new Programmer of Iphone..... i have a little problem in accessing
I have a little problem with new iPhone notification center. I have a fullscreen
Having an interesting little problem with my iPhone app. I have a view with

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.