看afn的代码的时候看到一个宏 TARGET_OS_WATCH 在AFURLSessionManager这个类中写的,我一时不知道这是什么意思,全局搜索了一下 找不到,
网络上对他的解释 存在于
搜索下大概的意思就是如下,判断是不是ios mac 或者watch的:
光用TARGET_OS_MAC并不能够区分ios和mac,需要像这样:
#if TARGET_OS_IPHONE
#define VIEW_CLASS UIView
#elif TARGET_OS_MAC
#define VIEW_CLASS NSView
#endif
先检查TARGET_OS_IPHONE 这个宏,在ios下(无论真机还是模拟器)该宏被定义;若未定义该宏则检查TARGET_OS_MAC。关于这些宏的定义 都暗暗存在了TargetConditionals.h
/*
* Copyright (c) 2000-2014 by Apple Inc.. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
/*
File: TargetConditionals.h
Contains: Autoconfiguration of TARGET_ conditionals for Mac OS X and iPhone
Note: TargetConditionals.h in 3.4 Universal Interfaces works
with all compilers. This header only recognizes compilers
known to run on Mac OS X.
*/
#ifndef __TARGETCONDITIONALS__
#define __TARGETCONDITIONALS__
/****************************************************************************************************
TARGET_CPU_*
These conditionals specify which microprocessor instruction set is being
generated. At most one of these is true, the rest are false.
TARGET_CPU_PPC - Compiler is generating PowerPC instructions for 32-bit mode
TARGET_CPU_PPC64 - Compiler is generating PowerPC instructions for 64-bit mode
TARGET_CPU_68K - Compiler is generating 680x0 instructions
TARGET_CPU_X86 - Compiler is generating x86 instructions
TARGET_CPU_ARM - Compiler is generati