I have NSBundle issues can anyone help?

Discussion in 'iOS Development' started by davidlansalot, Mar 19, 2009.

  1. davidlansalot

    davidlansalot New Member

    Joined:
    Oct 29, 2007
    Messages:
    213
    Likes Received:
    0
    Device:
    2G iPod touch
    Code:
    #import "MainView.h"
    #import "SoundEffect.h"
    
    @implementation MainView
    
    -(void)awakeFromNib 
    {
    	NSBundle *mainBundle = [NSBundle mainBundle];
    	soundEffect = [[SoundEffect alloc] initWithContentsOfFile:[mainBundle pathForResouce:@"knife" ofType:@"wav"]];
    }
    
    - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
    	[soundEffect play];
    }
    
    
    @end
    
    Then i get the warning "NSBundle may not respond to pathForResource:OfType:

    Can anyone help me? thanks
  2. JoshuaCaputo

    JoshuaCaputo New Member

    Joined:
    Aug 2, 2008
    Messages:
    605
    Likes Received:
    0
    Device:
    iPod touch
    you needa declare it in the header.

    SoundEffect *selectSound;

    and in the .m

    //Load Sounds ----------------->
    NSBundle *mainBundle = [NSBundle mainBundle];
    selectSound = [[SoundEffect alloc] initWithContentsOfFile:[mainBundle pathForResource

    Please Register or Log in to view images

    "Select" ofType

    Please Register or Log in to view images

    "caf"]];
  3. davidlansalot

    davidlansalot New Member

    Joined:
    Oct 29, 2007
    Messages:
    213
    Likes Received:
    0
    Device:
    2G iPod touch
    Code:
    #import <UIKit/UIKit.h>
    #import <Foundation/Foundation.h>
    
    @class SoundEffect;
    
    @interface MainView : UIView {
        IBOutlet UIImageView *knifeImage;
    	SoundEffect *soundEffect;
    }
    
    @end
    I did and I still get the warning
  4. gojohnnyboi

    gojohnnyboi Well-Known Member

    Joined:
    Jan 25, 2008
    Messages:
    3,339
    Likes Received:
    55
    im not going to say this will necessarily fix your problem, but why wouldn't you just do this:

    Code:
    [blah sendmsg:[[NSBundle mainBundle] pathForResource:@"BLAH" ofType:@"jimmy"]];
  5. JoshuaCaputo

    JoshuaCaputo New Member

    Joined:
    Aug 2, 2008
    Messages:
    605
    Likes Received:
    0
    Device:
    iPod touch
    I have the exact same code used in my apps, must be something wrong somewhere.
  6. davidlansalot

    davidlansalot New Member

    Joined:
    Oct 29, 2007
    Messages:
    213
    Likes Received:
    0
    Device:
    2G iPod touch
    alright thanks for the advice guys

Share This Page