Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 08-08-2010, 02:04 PM   #1 (permalink)
Nerd.
 
Join Date: Jun 2010
Location: In a house
Posts: 458
BillyGiggles is on a distinguished road
Default How do i fix this warning?

When i play a sound using the code..

Code:
- (IBAction)JazzBass{
	
	NSString *path = [[NSBundle mainBundle] pathForResource:@"JazzBass" ofType:@"mp3"];
	AVAudioPlayer* theAudio = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
	theAudio.delegate = self;
	
	[theAudio play];
	
}
The warning is on the line that says..

Code:
theAudio.delegate = self;
The warning is..


warning: class 'jazzDrumsCowbellLeft' does not implement the 'AVAudioPlayerDelegate' protocol

Any one know how to fix it?

thanks
BillyGiggles is offline   Reply With Quote
Old 08-08-2010, 02:07 PM   #2 (permalink)
Banned
 
Join Date: May 2010
Location: New Jersey
Posts: 595
Chessin is on a distinguished road
Send a message via AIM to Chessin
Default

I have the same problem and its really annoying, please someone help us out.
Chessin is offline   Reply With Quote
Old 08-08-2010, 02:29 PM   #3 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 139
dudeofswim is on a distinguished road
Default

Quote:
Originally Posted by Chessin View Post
I have the same problem and its really annoying, please someone help us out.
Me too! I dont worry about it htough

Tutorial: Easy Audio Playback With AVAudioPlayer
dudeofswim is offline   Reply With Quote
Old 08-08-2010, 02:38 PM   #4 (permalink)
Registered Member
 
Join Date: Jun 2009
Location: Ypsilanti, Michigan
Age: 63
Posts: 1,549
RLScott is on a distinguished road
Default

Quote:
Originally Posted by BillyGiggles View Post

The warning is..


warning: class 'jazzDrumsCowbellLeft' does not implement the 'AVAudioPlayerDelegate' protocol

Any one know how to fix it?

thanks
Post your interface declaration of jazzDrumsCowbellLeft class.
RLScott is offline   Reply With Quote
Old 08-08-2010, 02:51 PM   #5 (permalink)
Nerd.
 
Join Date: Jun 2010
Location: In a house
Posts: 458
BillyGiggles is on a distinguished road
Default

Uh well im playing around 150 sounds and they all have this warning
This is my whole .h file (for one class)

Code:

@interface jazzDrumsCowbellLeft : UIViewController {

}

-(IBAction)highSound;
-(IBAction)lowSound;
- (IBAction)goJazzSet;
- (IBAction)JazzBass;
- (IBAction)JazzCrash;
- (IBAction)JazzHiTom;
- (IBAction)JazzLowTom;
- (IBAction)JazzRide;
- (IBAction)JazzMidTom;
- (IBAction)RideBell;
- (IBAction)brush1;
- (IBAction)brush2;
- (IBAction)hihatO;
- (IBAction)hihatC;
- (IBAction)Snare;
- (IBAction)goBack;
BillyGiggles is offline   Reply With Quote
Old 08-08-2010, 02:53 PM   #6 (permalink)
Cocoa Junkie
 
Duncan C's Avatar
 
Join Date: Dec 2008
Location: Northern Virginia
Posts: 6,003
Duncan C has a spectacular aura about
Default

Quote:
Originally Posted by BillyGiggles View Post
When i play a sound using the code..

Code:
- (IBAction)JazzBass{
	
	NSString *path = [[NSBundle mainBundle] pathForResource:@"JazzBass" ofType:@"mp3"];
	AVAudioPlayer* theAudio = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
	theAudio.delegate = self;
	
	[theAudio play];
	
}
The warning is on the line that says..

Code:
theAudio.delegate = self;
The warning is..


warning: class 'jazzDrumsCowbellLeft' does not implement the 'AVAudioPlayerDelegate' protocol

Any one know how to fix it?

thanks
The compiler is telling you exactly what you need to do. The jazzDrumsCowbellLeft class needs to implement the AVAudioPlayerDelegate protocol. To add a protocol to an object, you need to do a couple of things. First, add the protocol to the interface for your class, like this:


@interface jazzDrumsCowbellLeft : parentClass <AVAudioPlayerDelegate>


Replace "parentClass" with whatever class your jazzDrumsCowbellLeft class inherits from.

The protocol(s) your class supports go inside the angle brackets, separated by commas. In this case we're only listing one protocol, AVAudioPlayerDelegate.

The next step is to look up the AVAudioPlayerDelegate protocol in the XCode docs and see what methods you need to implement to support that protocol.

Checking the docs, it says:

"The delegate of an AVAudioPlayer object must adopt the AVAudioPlayerDelegate protocol. All of the methods in this protocol are optional. They allow a delegate to respond to audio interruptions and audio decoding errors, and to the completion of a sound’s playback."

Since all the methods are optional, you don't HAVE to implement any of them. The audioPlayerDidFinishPlaying:successfully: is probably the most useful delegate method - it lets you get notified when the sound finishes playing. This would let you play a list of sounds one right after the other, for example.
__________________
Regards,

Duncan C
WareTo

Check out our apps in the Apple App store


Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.

See this tutorial on using UIView animations and layer animations:

See this thread on generating random, non-repeating text

Check out a very cool Macintosh Kaleidoscopes app called ScopeWorks that we released to the Mac App store.
Duncan C is offline   Reply With Quote
Old 08-09-2010, 06:37 PM   #7 (permalink)
Nerd.
 
Join Date: Jun 2010
Location: In a house
Posts: 458
BillyGiggles is on a distinguished road
Default

Hey thanks for helping out but since im still a noob what is a "parentClass"

Also where would i put the audioPlayerDidFinishPlaying:successfully:

Would i put it in..

Code:
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
}
Thats just a guess
BillyGiggles is offline   Reply With Quote
Old 08-09-2010, 06:48 PM   #8 (permalink)
Registered Member
 
Join Date: Jun 2009
Location: Ypsilanti, Michigan
Age: 63
Posts: 1,549
RLScott is on a distinguished road
Default

Quote:
Originally Posted by BillyGiggles View Post
Hey thanks for helping out but since im still a noob what is a "parentClass"...
It is the class from which the class in question inherits. In your case, you have defined jazzDrumsCowbellLeft with UIViewController as the parent class.

If you don't already have a book on Objective C, I recommend "Programming in Objective-C" by Stephen G. Kochan.
RLScott is offline   Reply With Quote
Old 08-10-2010, 01:55 AM   #9 (permalink)
Registered Member
 
Join Date: Jul 2010
Location: Enschede, Netherlands
Posts: 198
rickrets is on a distinguished road
Default

Quote:
Originally Posted by BillyGiggles View Post
Hey thanks for helping out but since im still a noob what is a "parentClass"

Also where would i put the audioPlayerDidFinishPlaying:successfully:

Would i put it in..

Code:
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
}
Thats just a guess
It's a method on it's own,

It would somewhat look like this:
Code:
- (void)audioPlayerDidFinishPlaying:successfully: {
//
//put code to play next sound, like Duncan said..
//
}
rickrets is offline   Reply With Quote
Old 08-10-2010, 08:39 AM   #10 (permalink)
iPhone SDK learner
 
Join Date: Feb 2010
Location: Illinois, USA
Posts: 421
Batman is on a distinguished road
Default

Quote:
Originally Posted by rickrets View Post
Code:
- (void)audioPlayerDidFinishPlaying:successfully: {
//
//put code to play next sound, like Duncan said..
//
}
Would be more like
Code:
- (void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)player successfully:(BOOL)flag {
//
//put code to play next sound, like Duncan said..
//
}
__________________
Fast Flash Cards
Available on the App Store
Fast Flash Cards
Batman is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 332
10 members and 322 guests
arash5500, HemiMG, iram91419, linkmx, mediaspree, Objective Zero, Paul Slocum, stanny, Touchmint, v1n2e7t
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,656
Threads: 94,116
Posts: 402,889
Top Poster: BrianSlick (7,990)
Welcome to our newest member, iram91419
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 11:34 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0