Sunday, April 21, 2013

NSFileManager contentsAtPath example objc


contentsAtPath:

Returns the contents of the file at the specified path.
- (NSData *)contentsAtPath:(NSString *)path
Parameters
path
The path of the file whose contents you want.
Return Value of [NSFileManager contentsAtPath]
An NSData object with the contents of the file. If path specifies a directory, or if some other error occurs, this method returns nil.

Example of [NSFileManager contentsAtPath]

NSString *plistPath = [[NSBundle mainBundle] pathForResource:@"Defaults" ofType:@"plist"];

NSData *plistXML = [[NSFileManager defaultManager] contentsAtPath:plistPath];