views:

77

answers:

2

I'm trying to point to the documents directory instead of the Bundle, I have the following code:

    - (id)initWithLibraryName:(NSString *)libraryName {
         if (self = [super init]) {
             libraryPlist = libraryName;
             libraryContent = [[NSArray alloc] initWithContentsOfFile:[[NSBundle mainBundle] 
                                        pathForResource:libraryPlist ofType:@"plist"]];

I know I need to point the app to the documents directory using the following:

      NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
      NSString *documentsDirectory = [paths objectAtIndex:0];

My question is where do I insert this pointer in the above example?

A: 
[[NSBundle mainBundle] pathForResource:libraryPlist ofType:@"plist"];

Is equivalent too:

[documentsDirectory stringByAppendingPathComponent:[libraryPlist stringByAppendingPathExtension:@"plist"]];

Except that the bundle call will return nil if the file does not exist. You can use fileExistsAtPath: in NSFileManager to check if a file exists.

drawnonward
Do I still need to put in this:NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0];to point it to the right place?
Michael Robinson
Got it figured out, thanks for the start.
Michael Robinson
A: 

Hi !

I'm beginner and I try to understand... HOW I can make a request to show all data (from plist) in SAME category (NOT ALL !) for exemple : show only the movie have : genre = Action

Please help me ... Thanks a lot ! Excuse my bad english !

Is it in this code I must make it or an other ???

  • (id)initWithLibraryName:(NSString *)libraryName { if (self = [super init]) { libraryPlist = libraryName; libraryContent = [[NSArray alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:libraryPlist ofType:@"plist"]];

==================================== HOW I can make a request to show from data plist only one categoy for exemple : show for the movie : category = Action

you can download the source for help me on : http://www.iphonedevcentral.com/wp-content/uploads/2009/08/MyDVDLibrary03.zip PLEASE SAY ME HOW I CAN DO IT !

I will want to know the exact CODE LINE and WHERE I must write it ! For see a the list of product are in Action.

THANKS VERY VERY MUCH Are you near France ? for say to you : THANKS, I can send a product of my country if you help me for my appli and maybe more...

Fraise
You should get the "beginning iphone 3 development book".
Michael Robinson