中文字幕av专区_日韩电影在线播放_精品国产精品久久一区免费式_av在线免费观看网站

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

NSString_InstanceMethods

發布時間:2020-07-09 06:08:00 來源:網絡 閱讀:282 作者:zhangjiansong0 欄目:開發技術

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;


向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

年辖:市辖区| 石家庄市| 辽源市| 内丘县| 涞源县| 陕西省| 邹城市| 南丰县| 肇源县| 青川县| 冀州市| 年辖:市辖区| 阳东县| 洪洞县| 德化县| 泸定县| 梨树县| 嘉定区| 昆明市| 张家川| 高淳县| 金寨县| 电白县| 卫辉市| 蕉岭县| 大悟县| 桐柏县| 阿拉善左旗| 龙泉市| 灵寿县| 玉树县| 新乡市| 巴林右旗| 长顺县| 上高县| 河间市| 柳州市| 高平市| 赤水市| 南投市| 汝南县|