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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T09:57:02+00:00 2026-05-20T09:57:02+00:00

in my tableViewController on – (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { i push my viewController

  • 0

in my tableViewController on

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

i push my viewController

        [self.navigationController pushViewController:[[[UIViewController alloc] initWithNibName:@"myViewController" bundle:nil] autorelease] animated:YES];

in myViewController i’ve import AVFoundation and add via IB three buttons for play/pause/stop a song

myViewController.h
#import <UIKit/UIKit.h>
#import <AVFoundation/AVFoundation.h>

@interface fotos : UIViewController <AVAudioPlayerDelegate> {
AVAudioPlayer *player;

}

@property (nonatomic, retain) AVAudioPlayer *player;

-(IBAction)play:(id)sender;
-(IBAction)pause:(id)sender;
-(IBAction)stop:(id)sender;

and i’ve implement in this way

myViewController.m
@implementation fotos
@synthesize player;

- (void)viewDidLoad {
[super viewDidLoad];
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"peter"                                                          
ofType:@"mp3"];

NSURL *fileURL = [[NSURL alloc] initFileURLWithPath:filePath];

player = [[AVAudioPlayer alloc] initWithContentsOfURL:fileURL error:nil];
player.delegate = self;
[player prepareToPlay];
[filePath release];
[fileURL release];  
}

-(IBAction)play:(id)sender {

if(!player.playing)
{
 [player play];
}
}

-(IBAction)pause:(id)sender {
[player pause];
}

-(IBAction)stop:(id)sender {
[player stop];
}

i’ve connect my action in IB but when i try to play my file i get

 *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-    
[UIViewController play:]: unrecognized selector sent to instance 0x5619e70'
*** Call stack at first throw:
(
0   CoreFoundation                      0x01009be9 __exceptionPreprocess + 185
1   libobjc.A.dylib                     0x0115e5c2 objc_exception_throw + 47
2   CoreFoundation                      0x0100b6fb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
3   CoreFoundation                      0x00f7b366 ___forwarding___ + 966
4   CoreFoundation                      0x00f7af22 _CF_forwarding_prep_0 + 50
5   UIKit                               0x0041ea6e -[UIApplication sendAction:to:from:forEvent:] + 119
6   UIKit                               0x004ad1b5 -[UIControl sendAction:to:forEvent:] + 67
7   UIKit                               0x004af647 -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
8   UIKit                               0x004ae1f4 -[UIControl touchesEnded:withEvent:] + 458
9   UIKit                               0x004430d1 -[UIWindow _sendTouchesForEvent:] + 567
10  UIKit                               0x0042437a -[UIApplication sendEvent:] + 447
11  UIKit                               0x00429732 _UIApplicationHandleEvent + 7576
12  GraphicsServices                    0x01b18a36 PurpleEventCallback + 1550
13  CoreFoundation                      0x00feb064 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
14  CoreFoundation                      0x00f4b6f7 __CFRunLoopDoSource1 + 215
15  CoreFoundation                      0x00f48983 __CFRunLoopRun + 979
16  CoreFoundation                      0x00f48240 CFRunLoopRunSpecific + 208
17  CoreFoundation                      0x00f48161 CFRunLoopRunInMode + 97
18  GraphicsServices                    0x01b17268 GSEventRunModal + 217
19  GraphicsServices                    0x01b1732d GSEventRun + 115
20  UIKit                               0x0042d42e UIApplicationMain + 1160
21  Training Cocoa                      0x00001bc4 main + 102
22  Training Cocoa                      0x00001b55 start + 53
)
terminate called after throwing an instance of 'NSException'

i’ve also try to play in viewDidLoad but nothing.

Any suggestion?
Thank’s

  • 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-20T09:57:02+00:00Added an answer on May 20, 2026 at 9:57 am

    Since player is a property try referencing it by
    [self player]

    so you might have [[self player] play];

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

Sidebar

Related Questions

I have got a tableViewController with one section and one cell. How can I
In my tableview, I load a custom cell from a nibFile: customCell = (cellReponseCircuit
I have subclassed UITableViewCell to make a custom cell for a tableView. I add
I have a NIB file with a custom UITableViewCell inside. I don't subclass UITableViewCell
i used the instruments to find leaks in my iphone app and i found
I need a small help. In my project there is a tab bar. On
I wonder if someone can help me out with regards to the memory management
I decided to get back to Cocoa/Objective-C programming recently and my current project calls
I am fairly new to iPhone/ObjC programming, though I have several years of experience
I have an App and, when I press the 'i' button, to show the

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.