I'd just like an Example Project.
Here are a couple dozen complete iOS example apps:
http://www.appsamuck.com/
One that uses sound is iDrum:
http://www.appsamuck.com/day21.html
I recommend starting with the 1st app, and not skipping the first 20 "days". I also recommend studying the source code, so you know what all the parts are, and how the Objective-C classes are actually written. For example, you're missing the @end statement in a lot of your posted code, or you've mistakenly stuck an @interface inside a different @implementation.
If you don't understand the Objective-C language, then you won't be able to understand what these apps do, nor be able to modify them to do something different. That seems to be the point that others have made: you're not even close to having the right syntax or structure for your Objective-C code.
You may have put together an app using copy/paste and some amount of luck, but you've now hit the wall. You need to understand the actual syntax and structure of Objective-C before you can get any further. The code you've posted so far is a complete mess, with pieces apparently pasted together in completely wrong ways. If it were an anatomy example, you've got the esophagus attached to the brain stem, and pieces of liver or spleen randomly attached as fingers and toes. I've been following the thread, and I have no idea how to even begin to rewrite it correctly for you, because I can't tell what kind of overall structure you want to have. I'm not saying I would rewrite it, just that if there's no discernable structure, it's not even possible to tell what the intent was.
EDIT:
Code dissection follows.
Code:
// Copyright 2011 __A.P.P.S__. All rights reserved.
//
#import "Homestar_SFXViewController.h"
You haven't posted the code for "Homestar_SFXViewController.h".
I presume it contains the @interface for the Homestar_SFXViewController class.
It's impossible to fully understand what a class is or does without seeing its @interface. First, the @interface tells what the superclass is. Without that, we can't tell whether it's a view class, an NSObject, or something else. The superclass also tells what methods and instance variables are inherited, which is very important.
Second, @interface tells what the new class's instance variables and new methods are. Without that, it's impossible to tell what the implementation is referring to when it makes a reference to a variable name not defined in a function or method.
You haven't posted the code for this header, either.
Code:
#import <AVFoundation/AVFoundation.h>
@implementation Homestar_SFXViewController
The @implementation line begins the implementation section for the Homestar_SFXViewController class.
Once an implementation section is started, you can't start any other @implementation or @interface sections until after the @end statement that terminates the first @implementation.
Code:
@interface SomeClass {
NSArray *theAudio; // this should fix the compiler error
}
// If the filteredChildren method is public, add this declaration as well to prevent compiler warnings
- (NSArray *)theAudio;
I have no idea what the intent of this is. I see no filteredChildren method, so even the comment is indecipherable.
First, it's an @interface nested inside another class's @implementation, which is not allowed. Second, it's a class named with the uninformative SomeClass name. Third, it's not a subclass of NSObject or any other discernible class, which means it won't work with alloc, init, retain, release or any of the other methods it will need. It doesn't implement the NSObject protocol, either. Fourth, it has an instance variable declared as NSArray*, although that's completely the wrong type if you're expecting it to serve as the variable that holds the AVAudioPlayer created in viewDidLoad.
Finally, even if you were allowed to nest an @interface within an @implementation, you're missing the @end that terminates the @interface.
Code:
- (void)viewDidLoad {
NSString *path = [[NSBundle mainBundle] pathForResource:@"hrintro" ofType:@"wav"];
theAudio = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
theAudio.delegate = self;
theAudio.numberOfLoops = 0;
[theAudio play];
[super viewDidLoad];
}
I have no idea if this method is supposed to belong to SomeClass or to Homestar_SFXViewController.
If it's intended for SomeClass, then you've failed to start an @implementation for it. If it's for Homestar_SFXViewController, then we have no way of knowing what superclass it is, what protocol it implements, what instance variables it has, etc. because you haven't posted the @interface for it. That means we have no way of really understanding what it's doing (or attempting to do).
If you're expecting the variable named
theAudio defined in SomeClass's @interface to somehow be merged into Homestar_SFXViewController, then you really have no understanding how classes are defined in Objective-C.
Code:
- (IBAction) myTap: (id) sender
{
[theAudio stop];
}
- (void)dealloc {
[theAudio release];
[super dealloc];
}
Same things here: no idea which class these methods should belong to, no idea which instance variable theAudio is referring to, etc.
Code:
-(IBAction)switchview:(id)sender {
soundboard *second = [[soundboard alloc] initWithNibName:nil bundle:nil];
second.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:second animated:YES];
}
You have some very similar code in your failed @implementation section for the soundboard class.
No idea if this similarity or near-duplication is intentional or not. No idea if the soundboard class or Homestar_SFXViewController are really subclasses of a suitable view controller superclass. I might guess that one of them is, and it's not soundboard, so no idea whether it makes any sense to present an instance of soundboard as a modal view controller.