NSString_InstanceMethods-创新互联

NSString

创新互联建站网站建设服务商,为中小企业提供做网站、成都网站设计服务,网站设计,成都网站托管等一站式综合服务型公司,专业打造企业形象网站,让您在众多竞争对手中脱颖而出创新互联建站

Inherits from: NSObject

Conforms to: NSObject, NSMutableCopying, NSSecureCoding, NSCopying

    stringByTrimmingCharactersInSet:

Returns a new string made by removing from both ends of the receiver characters contained in a given character set.

- (NSString *)stringByTrimmingCharactersInSet:(NSCharacterSet *)set

Parameters

set

A character set containing the characters to remove from the receiver. set must not be nil.

Return Value

A new string made by removing from both ends of the receiver characters contained in set. if the receiver is composed entirely of characters from set, the empty string is returned.

Discussion

Use whitespaceCharacterSet or whitespaceAndNewlineCharacterSet to remove whitespace around strings.

    rangeOfString:

Finds and returns the range of the first occurrence of a given string within the receiver.

- (NSRange)rangeOfString:(NSString *)aString

Parameters

aString

The string to search for. This value must not be nil.

Raises an NSInvalidArgumentException if aString is nil.

Return Value

An NSRange structure giving the location and length in the receiver of the first occurrence of aString. Returns {NSNotFound, 0} if aString is not found or is empty (@“”).

e.g.

NSRange *range = [“http://unpbook.com/small.git” rangeOfString:@“://”];

log:range.location = 4,length = 3

Discussion

Invokes rangeOfString:options: with no options.

    compare:options:

Compares the string with the specified string using the given options.

- (NSComparisonResult)compare:(NSString *)aString options:(NSStringCompareOptions)mask

Parameters

aString

The string with which to compare the receiver.

This value must not be nil. If this value is nil, the behavior is undefined and may change in future versions of OS X.

mask

Options for the search—you can combine any of the following using a C bitwise OR operator: NSCaseInsensitiveSearch, NSLiteralSearch, NSNumericSearch. See String Programming Guide for details on these options.

        NSCaseInsensitiveSearch 不区分大小写

NSLiteralSearch 区分大小写

NSNumericSearch 只比较字符串的个数,而不比较字符串的字面值

Return Value

The result of invoking compare:options:range: with a given mask as the options and the receiver’s full extent as the range.

Discussion

If you are comparing strings to present to the end-user, you should typically use localizedCompare: or localizedCaseInsensitiveCompare: instead, or use compare:options:range:locale: and pass the user’s locale.

e.g.

    NSString *scheme;

    if ([scheme compare:@"http"] options:NSCaseInsensitiveSearch] == NSOrderedSame)

additional

    NSComparisonResult
    These constants are used to indicate how items in a request are ordered.
    enum {
   NSOrderedAscending = -1,
   NSOrderedSame,
   NSOrderedDescending
};
typedef NSInteger NSComparisonResult;

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


名称栏目:NSString_InstanceMethods-创新互联
文章地址:http://lszwz.com/article/isdjd.html

其他资讯

售后响应及时

7×24小时客服热线

数据备份

更安全、更高效、更稳定

价格公道精准

项目经理精准报价不弄虚作假

合作无风险

重合同讲信誉,无效全额退款