• 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: Problem with fileAttributesAtPath
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem with fileAttributesAtPath


  • Subject: Re: Problem with fileAttributesAtPath
  • From: Jason Coco <email@hidden>
  • Date: Mon, 18 Aug 2008 15:36:26 -0400

If you're using 10.5 you can try the method:

-(NSDictionary *)attributesOfItemAtPath:(NSString *)path error: (NSError **)error

This way you will get a description of what is failing from the NSError object. You can use it like this:

NSError *theError;
NSDictionary *fileAttributes = [manager attributesOfItemAtPath:fullPath error:&theError];


if( fileAttributes != nil ) {
// do your things
} else {
NSLog(@"Error retrieving file attributes for %@: %@", fullPath, [theError localizedDescription]);
}


That should help you track down what might be going wrong at least....

On Aug 18, 2008, at 15:24 , Nicolas Goles wrote:

Hi guys, I am trying to get fileAttributesAtPath using this code: (files
contains the path to the directory that was enumerated )


       while(object = [dirEnumerator nextObject])
       {

           //First We craft the whole path for a single object

NSString *fullPath = [files stringByAppendingString:object];

NSLog(@"%@",fullPath); //Log the full path just to be sure it's
correct


           if(!fullPath)
           {
               NSLog(@"Error when appending strings");
           }

           //Try to obtain fileAttributes
           NSDictionary *fileAttributes = [manager
fileAttributesAtPath:fullPath traverseLink:NO];

           if( fileAttributes != nil)
           {

               NSString *filetype = [fileAttributes
objectForKey:NSFileType];
               NSLog(@"%@",filetype);
           }

           if(!fileAttributes)
           {
               NSLog(@"it's nill");
           }
    }

The thing is that my fileAttributes it's always = nil so I always get "it's
nill" on the console.


Could anyone point me at what I'm doing wrong ???

Thanks!! :)

--
-Nicolas Goles
_______________________________________________

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:
@gmail.com


This email sent to email@hidden

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

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

References: 
 >Problem with fileAttributesAtPath (From: "Nicolas Goles" <email@hidden>)

  • Prev by Date: Problem with fileAttributesAtPath
  • Next by Date: Re: Problem with fileAttributesAtPath
  • Previous by thread: Problem with fileAttributesAtPath
  • Next by thread: Re: Problem with fileAttributesAtPath
  • Index(es):
    • Date
    • Thread