2012-01-26 9 views

Respuesta

8

Use attributesOfItemAtPath:error: en su lugar.

+0

'attributesOfItemAtPath: error:' no soporta enlaces simbólicos. Por lo tanto, su sugerencia no tiene el mismo comportamiento que 'traverseLink: YES' de la pregunta. –

0

Consideraciones especiales

Debido a que este método no devuelve información de error, se ha de utilizarse a partir de Mac OS X v10.5. Utilice setAttributes: ofItemAtPath: error: en su lugar.

link

+0

'attributesOfItemAtPath: error:' no admite el enlace simbólico. Por lo tanto, su sugerencia no tiene el mismo comportamiento que 'traverseLink: YES' de la pregunta. –

0

debe leer documentation:

fileAttributesAtPath:traverseLink:

Returns a dictionary that describes the POSIX attributes of the file specified at a given. (Deprecated in Mac OS X v10.5. Use attributesOfItemAtPath:error: instead.)

+0

'attributesOfItemAtPath: error:' no admite el enlace simbólico. Por lo tanto, su sugerencia no tiene el mismo comportamiento que 'traverseLink: YES' de la pregunta. –

4

uso attributesOfItemAtPath:error:

NSError* error; 
NSDictionary* attr = [[NSFileManager defaultManager] attributesOfItemAtPath:file error:&error]; 
+0

'attributesOfItemAtPath: error:' no admite el enlace simbólico. Por lo tanto, su código no tiene el mismo comportamiento que 'traverseLink: YES' de la pregunta. –

1

La respuesta aceptada olvidó de manejar traverseLink:YES de la cuestión.

Una respuesta mejorada está utilizando tanto attributesOfItemAtPath:error: y stringByResolvingSymlinksInPath:

NSDictionary* attr = [[NSFileManager defaultManager] attributesOfItemAtPath:[file stringByResolvingSymlinksInPath] error:nil]; 
Cuestiones relacionadas