Instance Method


Returns a Boolean value that indicates whether the files or directories in specified paths have the same contents.


- (BOOL)contentsEqualAtPath:(NSString *)path1 andPath:(NSString *)path2;



The path of a file or directory to compare with the contents of path2.


The path of a file or directory to compare with the contents of path1.

Return Value

YES if file or directory specified in path1 has the same contents as that specified in path2, otherwise NO.


If path1 and path2 are directories, the contents are the list of files and subdirectories each contains—contents of subdirectories are also compared. For files, this method checks to see if they’re the same file, then compares their size, and finally compares their contents. This method does not traverse symbolic links, but compares the links themselves.

See Also

Getting and Comparing File Contents

- contentsAtPath:

Returns the contents of the file at the specified path.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software