stringByAppendingPathComponent及他的删除函数 等系列函数

来源:互联网 发布:算法问题实战策略好吗 编辑:程序博客网 时间:2024/05/19 20:57

- (NSString *)stringByAppendingPathComponent:(NSString *)aString


aString is “scratch.tiff”:

Receiver’s String Value

Resulting String

/tmp

/tmp/scratch.tiff

/tmp/

/tmp/scratch.tiff

/

/scratch.tiff

“” (an empty string)

scratch.tiff

- (NSString *)stringByDeletingLastPathComponent

Receiver’s String Value

Resulting String

/tmp/scratch.tiff

/tmp

/tmp/lock/

/tmp

/tmp/

/

/tmp

/

/

/

scratch.tiff

“” (an empty string)


- (NSString *)stringByAppendingPathExtension:(NSString *)ext
ext is"tiff"

Receiver’s String Value

Resulting String

/tmp/scratch.old

/tmp/scratch.old.tiff

/tmp/scratch.

/tmp/scratch..tiff

/tmp/

/tmp.tiff

scratch

scratch.tiff

- (NSString *)stringByDeletingPathExtension

Receiver’s String Value

Resulting String

/tmp/scratch.tiff

/tmp/scratch

/tmp/

/tmp

scratch.bundle/

scratch

scratch..tiff

scratch.

.tiff

.tiff

/

/


- (NSString *)stringByAppendingString:(NSString *)aString
aString

The string to append to the receiver. This value must not be nil.

NSString *errorTag = @"Error: ";
NSString *errorString = @"premature end of file.";
NSString *errorMessage = [errorTag stringByAppendingString:errorString];

produces the string “Error:premature end of file.”.

0 0