AFMacros
AFMacros 为验证和访问常用目录或 info-plist 值提供了一些实用的宏命令
示例
CoreTextLabel * label = (id)@"String"; // Assign object of wrong type
if (AF_VALID(label, CoreTextLabel))
{
ZLog(@"%p is valid", label);
}
else
{
ZLog(@"%p is not valid", label);
}
NSArray * array = @[@"abc", @"def"]; // Array with two items
if (AF_VALID_NOTEMPTY(array, NSArray))
{
ZLog(@"%p is valid and contains at least one object", label);
}
else
{
ZLog(@"%p is not valid or empty", label);
}
// This will print item at index 1
ZLog(@"Object at index '%d' has value '%@'", 1, AF_ARRAY_OBJECT_AT_INDEX(array, 1));
// This will print 'nil' for invalid index 99
ZLog(@"Object at index '%d' has value '%@'", 99, AF_ARRAY_OBJECT_AT_INDEX(array, 99));
安装
将 AFMacros pod 添加到您的 Podfile 中。
$ vim Podfile
platform :ios, '5.0'
pod 'AFMacros', :head
然后您可以在项目中安装依赖项。
$ pod install
记得在构建时始终打开 Xcode workspace 而不是 project 文件。
$ open App.xcworkspace
要求
AFMacros 1.0 及更高版本需要 iOS 5.0 及以上。
ARC
AFMacros使用ARC。
如果您在非ARC项目中使用AFMacros,您需要将所有AFMacros源文件设置为-fobjc-arc
编译器标志。
在Xcode中设置编译器标志,转到您的活动目标并选择“构建阶段”标签。现在选择所有AFMacros源文件,按Enter,输入-fobjc-arc
或-fno-objc-arc
然后“完成”以启用或禁用AFMacros的ARC。
鸣谢
AFMacros由Daniel Kuhnke为appfarms GmbH & Co. KG创建。
许可
AFMacros可在MIT许可下使用。更多信息请参阅LICENSE文件。