iOS Foundation 框架概述文档:常量、数据类型、框架、函数、发布声明

iOS Foundation 框架概述文档:常量、数据类型、框架、函数、发布声明

太阳火神的美丽人生 (http://blog.csdn.net/opengl_es)

本文遵循“署名-非商业用途-保持一致”创作公用协议

转载请保留此句:太阳火神的美丽人生 -  本博客专注于 敏捷开发及移动和物联设备研究:iOS、Android、Html5、Arduino、pcDuino否则,出自本博客的文章拒绝转载或再转载,谢谢合作。


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;

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值