• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Bundle problems
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bundle problems


  • Subject: Re: Bundle problems
  • From: Greg Titus <email@hidden>
  • Date: Fri, 8 Jun 2001 22:04:27 -0700

On Friday, June 8, 2001, at 05:42 PM, Michael P. Rogers wrote:

> I am trying to follow the rules and load images from a bundle, as
> opposed to a separate directory. Unfortunately, I keep getting nil
> back from
>
> imageFiles = [NSBundle pathsForResourcesOfType:@"jpg"
> inDirectory:@"Images"];
[...]
> Any suggestions would be appreciated.

The problem you are having here is that you are using a class method
from NSBundle instead of an instance method. It is especially confusing
because Apple has a documentation error so both the class method and
instance method with this name have identical descriptions even though
they are different. (The instance method documentation is correct and
the class method documentation is wrong.)

In the class method case (as in your example) you actually need to pass
in a fully-qualified path for the directory to look in, and nil is an
error (as you discovered).

What you want is to look in a directory inside your particular bundle,
which means you want to call the instance method on the bundle which you
want to look inside of - which in this case is the main application
bundle for your app. So this code:

imageFiles = [[NSBundle mainBundle] pathsForResourcesOfType:@"jpg"
inDirectory:@"Images"];

... should do what you were expecting the class method to do.

Hope this helps,
--Greg


  • Follow-Ups:
    • Re: Bundle problems
      • From: "Michael P. Rogers" <email@hidden>
References: 
 >Bundle problems (From: "Michael P. Rogers" <email@hidden>)

  • Prev by Date: Re: 2 questions and 1 idea
  • Next by Date: Re: Bundle problems
  • Previous by thread: Bundle problems
  • Next by thread: Re: Bundle problems
  • Index(es):
    • Date
    • Thread