• 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
The ghost in the bundle
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

The ghost in the bundle


  • Subject: The ghost in the bundle
  • From: Pierre Berloquin <email@hidden>
  • Date: Fri, 30 Oct 2009 04:51:16 +0100

OK here is a mystery for you.
Before I knew how to use a Copy Files build phase, I placed a bunch of jpg's
in the scope of the product, dragged them in the Resources folder and hit
the bundle with

[listeImages addObjectsFromArray:[mainBundle pathsForResourcesOfType:@"jpg"
inDirectory:nil]];

That gave me 94 pictures that my app displayed and played with.
Now, I drag only 40 pictures in a subdirectory of Resources called Pics,
drag them in a Copy Files and name the directory Pics.
I hit the bundle with

[listeImages addObjectsFromArray:[mainBundle pathsForResourcesOfType:@"jpg"
inDirectory:@"Pics"]];

I get my 40 pictures OK that I can display and play with.

EXCEPT ... that just out of curiosity, I tried inDirectory:nil again and it
gave me my former 94 jpg's back, that I can display and play with. What
worries me is that they are not in Resources anymore and some were moved to
a directory outside the scope of the app. Worse : one of them, that was
moved AND renamed, is still loaded and displayed.
It looks like the app is going to carry a ghost load forever, that I don't
need.
What can I do?

Thanks
Pierre


2009/10/29 Ron Fleckner <email@hidden>

> Hmm... maybe I'm the dumb one.  I don't see why one would want to futz with
> a copy files build phase.  I've never done that and, as they say, It Just
> Works™.  Maybe I've been lucky...
>
> Ron
>
>
>
> On 29/10/2009, at 8:25 PM, Pierre Berloquin wrote:
>
>  I was quite dumb. Had I but read the documentation on Copy Files ...
>> Indeed the directory you enter there is the one you can access in the
>> bundle.
>> What I didn't see is that the files must be entered into the resources
>> first.
>> Just what I was looking for.
>>
>> I was misled by old blogs from the past, apparently before this was fixed.
>> I should have gone to the doc first
>>
>> Thanks
>>
>> Pierre
>>
>>
>> 2009/10/29 Ron Fleckner <email@hidden>
>> When you add your folder of jpgs to your project, be sure to set "Create
>> folder references for any added folders" to true.  Also don't forget to
>> check the checkbox with "Copy items into destination group's folder, if
>> needed."  Then you can do, for example:
>>
>>       NSString *bellSoundPath = [[NSBundle mainBundle] pathForResource:@"Cow
>> Bell" ofType:@"aiff" inDirectory:@"Sounds"];
>>
>> and it Just Works™.
>>
>> Ron
>>
>>
>>
>> On 29/10/2009, at 4:01 PM, Pierre Berloquin wrote:
>>
>> I do use pathForResource:ofType:inDirectory: with nil for Directory and
>> jpg
>> for Type
>> It helps separate jpg's from other pictures
>>
>> But suppose I want to have my pictures in a directory called Pic, how do I
>> go about it?
>> Thanks Dave
>> Pierre
>>
>> 2009/10/28 Dave Carrigan <email@hidden>
>>
>>
>> On Oct 28, 2009, at 10:46 AM, Pierre Berloquin wrote:
>>
>> My app uses a hundred pictures.
>> How can I group them somewhere in the bundle so that my app loads them
>> without confusing them with button images and icons .
>>
>>
>> Have you tried NSBundle's -pathForResource:ofType:inDirectory:
>>
>> To install them, create a new copy files build phase that copies them to
>> the subdirectory of your choosing.
>>
>> --
>> Dave Carrigan
>> email@hidden
>> Seattle, WA, USA
>>
>>
>>
>>
>>
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: The ghost in the bundle
      • From: Graham Cox <email@hidden>
  • Prev by Date: [iphone] in app store - remembering a purchase
  • Next by Date: Re: The ghost in the bundle
  • Previous by thread: Re: [iphone] in app store - remembering a purchase
  • Next by thread: Re: The ghost in the bundle
  • Index(es):
    • Date
    • Thread