iOS Foundation 框架概述文档:常量、数据类型、框架、函数、公布声明
iOS Foundation 框架概述文档:常量、数据类型、框架、函数、公布声明
太阳火神的漂亮人生 (http://blog.csdn.net/opengl_es)
本文遵循“署名-非商业用途-保持一致”创作公用协议
| Foundation 框架概述文档:常量、数据类型、框架、函数、公布声明 | ||
| Title | Topic | Date |
| 基础常量參考 Foundation Constants Reference |
A | Content Update |
| 基础数据类型參考 Foundation Data Types Reference |
A | Minor Change |
| 基础框架參考 Foundation Framework Reference |
A | Content Update |
| 基础函数參考 Foundation Functions Reference |
A | Minor Change |
| Foundation Release Notes for iOS |
A | First Version |
| Foundation Release Notes for OS X v10.9 | A | Content Update |
1、基础常量參考 Foundation
Constants Reference (下面仅选出经常使用的部分,完整列表可点击此行标题转入官网链接)
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;
NSComparisonResult
这些常量用于指示请求中的条目怎样排序。
These constants are used to indicate how items in a request are ordered.
enum {
NSOrderedAscending = -1,
NSOrderedSame,
NSOrderedDescending
};
typedef NSInteger NSComparisonResult;
NSSortOptions
块排序操作的选项。
Options for Block sorting operations.
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 NSIntegerMax LONG_MAX
#define NSIntegerMin LONG_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);
NSSetUncaughtExceptionHandler
Changes the top-level error handler.
void NSSetUncaughtExceptionHandler (
NSUncaughtExceptionHandler *
);
声明全局异常处理函数,它就是 NSUncaughtExceptionHandler *
void UncaughtExceptionHandler(NSException *exception) { // 获取异常相关信息
NSArray *callStackSymbols = [exception callStackSymbols];
NSString *callStackSymbolStr = [callStackSymbols componentsJoinedByString:@"\n"];
NSString *reason = [exception reason];
NSString *name = [exception name]; // 获取系统当前时间
NSDate * date = [NSDate date];
NSDateFormatter * dateFormatter = [[NSDateFormatter alloc] init ];
[dateFormatter setDateFormat:@"yyyy年MM月dd日 HH小时mm分ss秒"];
NSString * dateStr = [dateFormatter stringFromDate:date]; NSLog(@"系统当前时间为:%@ \n",dateStr);
NSLog(@"异常名称:%@ \n",name);
NSLog(@"异常原因:%@ \n",reason);
NSLog(@"堆栈标志:%@ \n",callStackSymbolStr);
}在应用适当初始化位置为系统设置该回调函数指针,AppDelegate 完毕启动方法中比較适合:
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
NSSetUncaughtExceptionHandler(&UncaughtExceptionHandler);
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
};
以上节选一部分经常使用的,从上面的链接,能够查看苹果官方文档完整部分。
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);
3、基础框架參考 Foundation
Framework Reference
和 JSON 解析、撤销与重做、定时器类、线程同步类、线程安全类、线程通讯类、网络类、文件
之 偏好设置即用户默认设置类、文件 之 应用包及沙盒管理类、文件 之 归档与串行化类、文件 之 流类、蓝牙点对点通讯类、其他用得不多的少许类。
Functions Reference
Assertions
For additional information about Assertions, see Assertions and Logging Programming Guide.
NSAssertNSAssert1NSAssert2NSAssert3NSAssert4NSAssert5NSCAssertNSCAssert1NSCAssert2NSCAssert3NSCAssert4NSCAssert5NSCParameterAssertNSParameterAssert
Bundles
For additional information on generating strings files see “Using Strings Files for User-Facing Text” in Internationalization
Programming Topics.
NSLocalizedStringNSLocalizedStringFromTableNSLocalizedStringFromTableInBundleNSLocalizedStringWithDefaultValue
Byte Ordering
NSConvertHostDoubleToSwappedNSConvertHostFloatToSwappedNSConvertSwappedDoubleToHostNSConvertSwappedFloatToHostNSHostByteOrderNSSwapBigDoubleToHostNSSwapBigFloatToHostNSSwapBigIntToHostNSSwapBigLongLongToHostNSSwapBigLongToHostNSSwapBigShortToHostNSSwapDoubleNSSwapFloatNSSwapHostDoubleToBigNSSwapHostDoubleToLittleNSSwapHostFloatToBigNSSwapHostFloatToLittleNSSwapHostIntToBigNSSwapHostIntToLittleNSSwapHostLongLongToBigNSSwapHostLongLongToLittleNSSwapHostLongToBigNSSwapHostLongToLittleNSSwapHostShortToBigNSSwapHostShortToLittleNSSwapIntNSSwapLittleDoubleToHostNSSwapLittleFloatToHostNSSwapLittleIntToHostNSSwapLittleLongLongToHostNSSwapLittleLongToHostNSSwapLittleShortToHostNSSwapLongNSSwapLongLongNSSwapShort
Decimals
You can also use the class NSDecimalNumber for
decimal arithmetic.
NSDecimalAddNSDecimalCompactNSDecimalCompareNSDecimalCopyNSDecimalDivideNSDecimalIsNotANumberNSDecimalMultiplyNSDecimalMultiplyByPowerOf10NSDecimalNormalizeNSDecimalPowerNSDecimalRoundNSDecimalStringNSDecimalSubtract
Exception Handling
You can find the following macros implemented in NSException.h. They are obsolete and should not be used. See Exception
Programming Topics for information on how to handle exceptions.
Managing Object Allocation and Deallocation
NSAllocateObjectNSCopyObjectNSDeallocateObjectNSDecrementExtraRefCountWasZeroNSExtraRefCountNSIncrementExtraRefCountNSShouldRetainWithZone
Interacting with the Objective-C Runtime
NSGetSizeAndAlignmentNSClassFromStringNSStringFromClassNSSelectorFromStringNSStringFromSelectorNSStringFromProtocolNSProtocolFromString
Logging Output
Managing File Paths
NSFullUserNameNSHomeDirectoryNSHomeDirectoryForUserNSOpenStepRootDirectoryNSSearchPathForDirectoriesInDomainsNSTemporaryDirectoryNSUserName
Managing Ranges
NSEqualRangesNSIntersectionRangeNSLocationInRangeNSMakeRangeNSMaxRangeNSRangeFromStringNSStringFromRangeNSUnionRange
Uncaught Exception Handlers
Whether there’s an uncaught exception handler function, any uncaught exceptions cause the program to terminate, unless the exception is raised during the posting of a notification.
Core Foundation ARC Integration
Managing Memory
NSAllocateMemoryPagesNSCopyMemoryPagesNSDeallocateMemoryPagesNSLogPageSizeNSPageSizeNSRealMemoryAvailableNSRoundDownToMultipleOfPageSizeNSRoundUpToMultipleOfPageSizeNSMakeCollectable
Managing Zones
Zones are ignored on iOS and 64-bit runtime on OS X. You should not use zones in current development.
iOS Foundation 框架概述文档:常量、数据类型、框架、函数、公布声明的更多相关文章
- 2013 最新的 play web framework 版本 1.2.3 框架学习文档整理
Play framework框架学习文档 Play framework框架学习文档 1 一.什么是Playframework 3 二.playframework框架的优点 4 三.Play Frame ...
- VS2010-MFC(利用MFC向导生成单文档应用程序框架)
一.VC++与MFC 讲VC++免不了要提MFC,MFC全称Microsoft Foundation Classes,也就是微软基础类库.它是VC++的核心,是C++与Windows API的结合,很 ...
- VUX 移动前端框架使用文档
VUX 移动前端框架使用文档 https://owlaford.gitbooks.io/vux-mobile-framework/content/index.html
- VS2010/MFC编程入门之二(利用MFC向导生成单文档应用程序框架)
VS2010/MFC编程入门之二(利用MFC向导生成单文档应用程序框架)-软件开发-鸡啄米 http://www.jizhuomi.com/software/141.html 上一讲中讲了VS20 ...
- MFC 应用、模板、框架、文档、视图 的关系
从该对象 如何访问其他对象 全局函数 调用全局函数AfxGetApp可以得到CWinApp应用类指针 应用 AfxGetApp()->m_pMainWnd为框架窗口指针:用CWinApp::Ge ...
- DL动态载入框架技术文档
DL动态载入框架技术文档 DL技术交流群:215680213 1. Android apk动态载入机制的研究 2. Android apk动态载入机制的研究(二):资源载入和activity生命周期管 ...
- drf框架接口文档
drf框架接口文档 REST framework可以自动帮助我们生成接口文档. 接口文档以网页的方式呈现. 自动接口文档能生成的是继承自APIView及其子类的视图. 一.安装依赖 pip insta ...
- 使用 NuGet 下载最新的 Rafy 框架及文档
为了让开发者更方便地使用 Rafy 领域实体框架,本月,我们已经把最新版本的 Rafy 框架程序集发布到了 nuget.org 上,同时,还把 RafySDK 的最新版本发布到了 VisualStud ...
- iOS开发主要参考文档(转载)
Objective-C,语言的系统详细资料.这是做iOS开发的前题与基础.https://developer.apple.com/library/ios/#documentation/Cocoa/Co ...
随机推荐
- IOS的XML文件解析,利用了NSData和NSFileHandle
如果需要了解关于文档对象模型和XML的介绍,参看 http://www.cnblogs.com/xinchrome/p/4890723.html 读取XML 上代码: NSFileHandle *fi ...
- 一天一个Java基础——序列化
1.概念 Java的“对象序列化”能将一个实现了Serializable接口的对象转换成一组byte,这样日后要用这个对象的时候,能把这些byte数据恢复出来,并据此重新构建那个对象. 对象序列化能实 ...
- 给Java新手的一些建议----Java知识点归纳(Java基础部分)
写这篇文章的目的是想总结一下自己这么多年来使用java的一些心得体会,主要是和一些java基础知识点相关的,所以也希望能分享给刚刚入门的Java程序员和打算入Java开发这个行当的准新手们,希望可以给 ...
- tcprstat的使用方式
两种使用方式:1)本机直接在线采集:2)分析tcpdump采集到的离线pcap文件 1. 本机直接在线采集 参数: -p :指定只采集此TCP port的请求 -t : 采集输出的时间间 ...
- MyBatis一对多双向关联——MyBatis学习笔记之七
处理has-one关系需要用到association元素,而处理has many关系则需要用到collection元素.例如本例中,假设一 名教师可同时指导多名学生,下面就来介绍如何使用collect ...
- Spring 事务管理原理探究
此处先粘贴出Spring事务需要的配置内容: 1.Spring事务管理器的配置文件: 2.一个普通的JPA框架(此处是mybatis)的配置文件: <bean id="sqlSessi ...
- C语言指针5分钟教程
指针.引用和取值 什么是指针?什么是内存地址?什么叫做指针的取值?指针是一个存储计算机内存地址的变量.在这份教程里“引用”表示计算机内存地址.从指针指向的内 存读取数据称作指针的取值.指针可以指向某些 ...
- python测试基于websocket协议的即时通讯接口
随着html5的广泛应用,基于websocket协议的即时通讯有了越来越多的使用场景,本文使用python中的websocket-client模块来做相关的接口测试 import webclient ...
- cxf 动态创建客户端,局域网能正常调用服务端,外网不能访问
- jquery阻止冒泡事件:$('span').bind("click",function(event){event.stopPropagation();})(有用源)
冒泡事件就是点击子节点,会向上触发父节点,祖先节点的点击事件. <body> <div id="content"> 外层div元素 <span> ...