检索文件
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory,
NSUserDomainMask, YES);
//获取关于本工程的一系列路径
NSString *documentsDirectory = [paths objectAtIndex:0];
//paths中是一个字符串数组,但往往只有第一个是期待得到的.
filePath = [documentsDirectory
stringByAppendingPathComponent:@"textviewcontent"];
//关于stringByAppendingPathComponent:的用法在下面有写到
[filePathretain];
NSFileManager *myFM = [NSFileManagerdefaultManager];
stringByAppendingPathComponent:
Returns a new string made by appending to the receiver a given string.
Parameters
- aString
-
The path component to append to the receiver.
Return Value
A new string made by appending aString to the receiver, preceded if necessary by a path separator.
Discussion
The following table illustrates the effect of this method on a variety of different paths, assuming that aString is supplied as “scratch.tiff”:
|
Receiver’s String Value |
Resulting String |
|---|---|
|
“ |
“ |
|
“ |
“ |
|
“ |
“ |
|
“” (an empty string) |
“ |
浙公网安备 33010602011771号