NSComparisonResul、NSNotFound、NSEnumerationOptions......的用处
NSNotFound
定义一个值,用于指示请求项找不到或不存在。
Defines a value that indicates that an item requested couldn’t be found or doesn’t exist.
enum { NSNotFound = NSIntegerMax};
NSEnumerationOptions
块枚举操作的选项。
Options for Block enumeration operations.
enum { NSEnumerationConcurrent = (1UL << 0), NSEnumerationReverse = (1UL << 1),};typedef NSUInteger NSEnumerationOptions;
Options:位枚举
NSString *str = @"abc";
NSString *str1 = @"Abc";
// 比较的时候不区分大小写
NSComparisonResult result = [str compare:str1 options:NSCaseInsensitiveSearch|];
switch (result) {
case NSOrderedAscending:
NSLog(@"str < str1,升序");
break;
case NSOrderedDescending:
NSLog(@"str > str1,降序");
break;
case NSOrderedSame:
NSLog(@"str == str1,");
break;
default:
break;
NSString *str = @"abc";
NSString *str1 = @"ab";
// 比较的时候不区分大小写和根据个数
NSComparisonResult result = [str compare:str1 options:NSCaseInsensitiveSearch|NSNumericSearch];
switch (result) {
case NSOrderedAscending:
NSLog(@"str < str1,升序");
break;
case NSOrderedDescending:
NSLog(@"str > str1,降序");
break;
case NSOrderedSame:
NSLog(@"str == str1,");
break;
default:
break;
NSComparisonResult
这些常量用于指示请求中的条目如何排序。
These constants are used to indicate how items in a request are ordered.
enum {
NSOrderedAscending = -1, -1 升序
NSOrderedSame, 0 降序
NSOrderedDescending 1 ==
};
typedef NSInteger NSComparisonResult;
NSString *str = @"abc";
NSString *str1 = @"abd";
NSComparisonResult result = [str compare:str1];
switch (result) {
case NSOrderedAscending:
NSLog(@"str < str1,升序");
break;
case NSOrderedDescending:
NSLog(@"str > str1,降序");
break;
case NSOrderedSame:
NSLog(@"str == str1,");
break;
default:
break;
NSSortOptions
块排序操作的选项。
Options for Block sorting operations.
struct NSSortOptions : RawOptionSetType {
init(_ rawValue: UInt)
init(rawValue rawValue: UInt)
static var Concurrent: NSSortOptions { get }
static var Stable: NSSortOptions { get }
}
enum { NSSortConcurrent = (1UL << 0), NSSortStable = (1UL << 4),};typedef NSUInteger NSSortOptions;
NSSearchPathDirectory
这些常量指定了各种目录位置,用于方法 URLsForDirectory:inDomains: 和 URLForDirectory:inDomain:appropriateForURL:create:error: NSFileManager 。
These constants specify the location of a variety of directories by the URLsForDirectory:inDomains: andURLForDirectory:inDomain:appropriateForURL:create:error: NSFileManager methods.
enum { NSApplicationDirectory = 1, NSDemoApplicationDirectory, NSDeveloperApplicationDirectory, NSAdminApplicationDirectory, NSLibraryDirectory, NSDeveloperDirectory, NSUserDirectory, NSDocumentationDirectory, NSDocumentDirectory, NSCoreServiceDirectory, NSAutosavedInformationDirectory = 11, NSDesktopDirectory = 12, NSCachesDirectory = 13, NSApplicationSupportDirectory = 14, NSDownloadsDirectory = 15, NSInputMethodsDirectory = 16, NSMoviesDirectory = 17, NSMusicDirectory = 18, NSPicturesDirectory = 19, NSPrinterDescriptionDirectory = 20, NSSharedPublicDirectory = 21, NSPreferencePanesDirectory = 22, NSItemReplacementDirectory = 99, NSAllApplicationsDirectory = 100, NSAllLibrariesDirectory = 101,};typedef NSUInteger NSSearchPathDirectory;
NSInteger and NSUInteger Maximum and Minimum Values
代表 NSInteger 和 NSUInteger 的最大值和最小值的常量。
Constants representing the maximum and minimum values of NSInteger and NSUInteger.
#define NSIntegerMaxLONG_MAX#define NSIntegerMinLONG_MIN #define NSUIntegerMax ULONG_MAX
2、基础数据类型参考 Foundation Data Types Reference (以下仅选出常用的部分,完整列表可点击此行标题转入官网链接)
NSInteger
用于描述一个整型。(这个不是一个类,而是一个宏定义,是 C 长整型的别名)
Used to describe an integer.
typedef long NSInteger;
NSUInteger
用于描述一个无符号整型。(这个也不是一个类,而是一个宏定义,是 C 无符号长整型的别名)
Used to describe an unsigned integer.
typedef unsigned long NSUInteger;
NSTimeInterval
用于指定一个时间间隔,单位 秒。
Used to specify a time interval, in seconds.
以下这句原文,后半句关于毫秒部分的精度,没太明白,有懂得帮准确翻译一下,在此谢过。NSTimeInterval is always specified in seconds; it yields sub-millisecond precision over a range of 10,000 years.
typedef double NSTimeInterval;
NSUncaughtExceptionHandler
用于处理异常处理域之外的异常。也即系统无法捕获的异常,配合 XCode 做异常跟踪很有用处。
Used for the function handling exceptions outside of an exception-handling domain.
typedef volatile void NSUncaughtExceptionHandler(NSException *exception);
NSStringEncoding
该类型代表字符串编码值。
Type representing string-encoding values.
typedef NSUInteger NSStringEncoding;
String Encodings
以下常量由 NSString 提供,作用可用的字符串编码。
The following constants are provided by NSString as possible string encodings.
enum { NSASCIIStringEncoding = 1,
。。。 NSUTF8StringEncoding = 4,
。。。 NSUnicodeStringEncoding = 10,
。。。 NSProprietaryStringEncoding = 65536};
以上节选一部分常用的,从上面的链接,可以查看苹果官方文档完整部分。
但是,你会发现没有 GB2312、GBK 等编码,这个可以通过核心基础框架来解决,在基础框架中并未提供相应的编码。
CFStringConvertEncodingToNSStringEncoding
Returns the Cocoa encoding constant that maps most closely to a given Core Foundation encoding constant.
unsigned long CFStringConvertEncodingToNSStringEncoding ( CFStringEncoding encoding);
CFStringConvertNSStringEncodingToEncoding
Returns the Core Foundation encoding constant that is the closest mapping to a given Cocoa encoding.
CFStringEncoding CFStringConvertNSStringEncodingToEncoding ( unsigned long encoding);
CFStringEncoding
An integer type for constants used to specify supported string encodings in various CFString functions.
typedef UInt32 CFStringEncoding;
External String Encodings
CFStringEncoding 常量用于可能被 CFString 支持的编码。 constants for encodings that may be supported by CFString.
CFStringEncoding
enum { 。。。 kCFStringEncodingGB_2312_80 = 0x0630, kCFStringEncodingGBK_95 = 0x0631, kCFStringEncodingGB_18030_2000 = 0x0632, 。。。 kCFStringEncodingBig5 = 0x0A03, 。。。 kCFStringEncodingHZ_GB_2312 = 0x0A05, 。。。};
kCFStringEncodingGB_18030_2000 是 GB 编码的最大集合,可以使用这个,用如下方式:
NSStringEncoding gbencoding = CFStringConvertEncodingToNSStringEncoding(kCFStringEncodingGB_18030_2000);
NSComparisonResul、NSNotFound、NSEnumerationOptions......的用处的更多相关文章
- 【repost】document.write的用处
document.write的用处 document.write是JavaScript中对document.open所开启的文档流(document stream操作的API方法,它能够直接在文档流中 ...
- 【转】代码中特殊的注释技术——TODO、FIXME和XXX的用处
(转自:http://blog.csdn.net/reille/article/details/7161942) 作者:reille 本博客网址:http://blog.csdn.net/reille ...
- 使用angular中ng-repeat , track by的用处
我们见到最简单的例子是: <div ng-repeat="link in links" ></div> 如果item的值有重复的,比如links=[&quo ...
- github的pull request是指什么意思?有什么用处
github的pull request是指什么意思? 来看看某乎某位阿牛的理解,多么的简单粗暴! 我尝试用类比的方法来解释一下 pull reqeust.想想我们中学考试,老师改卷的场景吧.你做的试卷 ...
- Docker对普通开发者的用处(转)
有些开发者可能还是不明白 Docker 对自己到底有多大的用处,因此翻译 Docker 个人用例 这篇文章中来介绍 Docker 在普通开发者开发过程中的用例. Docker 如今赢得了许多关注,很多 ...
- java中的反射机制在Android开发中的用处
JAVA反射机制是在运行状态中,对于任意一个类,都能够知道这个类的所有属性和方法:对于任意一个对象,都能够调用它的任意一个方法和属性:这种动态获取的信息以及动态调用对象的方法的功能称为java语言的反 ...
- 【译】ISupportInitialize的用处
[译]ISupportInitialize的用处 注:本文是对How ISupportInitialize Can Help的翻译.原文作者编写了Sharpgl,这篇文章是对制作Winform控件过程 ...
- 懒加载的用处和赋nil操作[iOS开发教程]
懒加载的用处和赋nil操作 1:数据,清空操作: self.array = nil; 2:归档从新从本地获取数据 self.archive = nil; ##id = nil的用处 block当参数, ...
- 演示save point及自治事务的用处
1.确认数据库版本 2 举一个例子,说明save point的用处,给出SQL演示. 2.1环境准备 save point的作用是通过在事务中间设置检查点,可以更加精细的控制事务,防止一部分操作错误而 ...
随机推荐
- Lua自己实现string.split功能
local function split(str, d) --str是需要查分的对象 d是分界符 local lst = { } local n = string.len(str)--长度 local ...
- 响应式布局2--MATE
随着高端手机(Andriod,Iphone,Ipod,WinPhone等)的盛行,移动互联应用开发也越来越受到人们的重视,用html5开发移动应用是最好的选择.然而,每一款手机有不同的分辨率,不同屏幕 ...
- Leetcode: Path Sum III
You are given a binary tree in which each node contains an integer value. Find the number of paths t ...
- Python快速建站系列-Part.Four-首页内容填充
|版权声明:本文为博主原创文章,未经博主允许不得转载. Part.Three中实现了注册和登录的功能,那这一节完成主页内容的填充,并且主页中要实现简单的可以查找代码的功能. 而且有于公共代码部分存储在 ...
- AJAX-----08jsonp跨域请求
jsonp跨域请求其实我个人感觉并非传统上的ajax,因为传统的ajax几乎都是采用了xmlhttprequest这个对象来进行发送数据或者接收数据而已, 而jsop是通过双方约定成一个接口文件,然后 ...
- PHP二维数组提取函数----把不需要的数据剔除
首先说明一些这个函数的应用场景,比如说你得到的数据是个二维数组,里面的很多成员其实是不必要的,比如说api调用后不必要给别人返回一些用不到的垃圾数据吧,如下是代码. <?php /* * del ...
- HTML5、CSS3响应式设计——笔记
1.1.响应式网页设计 响应式网页设计(RWD,Responsive Web Design)这个术语,由伊桑·马科特(EthanMarcotte)提出.他在A List Apart 发表了一篇开创性的 ...
- 随机获取数据库中的某一条数据(基于yii2框架开发)
注意: 使用PHP函数array_rand()得到的是这个数组中的那个值相对应的下标键值,需要配合原来的数组进行,例如: $rand_keys = array_rand($ids,1); $id = ...
- ASP.net解析JSON例子
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.We ...
- [转]iOS学习之UINavigationController详解与使用(三)ToolBar
转载地址:http://blog.csdn.net/totogo2010/article/details/7682641 iOS学习之UINavigationController详解与使用(二)页面切 ...