LLVM 4.0可以在Xcode 4.3中使用吗? [英] Can LLVM 4.0 Be Used in Xcode 4.3?

查看:77
本文介绍了LLVM 4.0可以在Xcode 4.3中使用吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

换句话说,使用文字,但目标是iOS 5.

In other words, use literals but target for iOS 5.

我知道

I am aware of this but that post is not conclusive.

推荐答案

您可以关闭编译器,但它可能无法正常工作(我刚刚尝试过).使用此新语法的编译SDK有一些要求(即,它可以在以前的iOS版本上运行,但是您需要使用iOS 6.0 SDK进行编译).我认为目前不允许在这里讨论它们,但是现代Objective-C" WWDC 2012视频中详细介绍了它们.

You can switch the compiler out, but it doesn't work as you might think (I tried it just now). There are a few requirements of the compiling SDK for using this new syntax (i.e. it will work on previous iOS versions, but you need to compile it with the iOS 6.0 SDK). I don't think I am allowed to discuss them here at the moment, but they are covered in detail in the "Modern Objective-C" WWDC 2012 video.

基本上,您将拥有语法,但是库将不知道如何响应.

Basically, you will have the syntax, but the libraries will not know how to respond to it.

尽管有另一种理论……我只是没有正确地做^^;

There is an alternate theory though...that I just didn't do it right ^^;

最后,您没有没有使用4.3部署到5.x应用程序.因此,我的建议只是升级,实际上没有任何缺点(除非您即将部署应用程序,但在那种情况下,由于我想您差不多完成了,因此转换所有内容都将很麻烦).

In the end though, you don't have to use 4.3 to deploy to 5.x apps. So my suggestion is just upgrade, there is really no downside to it (unless you are deploying an app soon, but in that case it would just be a hassle to convert everything since I assume you are almost done).

编辑(两个月后,现在iOS 6已公开).您绝对可以使用类别来避开新的Objective-C文字语法的SDK要求.分别在NSArrayNSDictionary上为- (id)objectAtIndexedSubscript:(NSUInteger)idx- (id)objectForKeyedSubscript:(id)key添加类别,这些类别仅返回objectAtIndex:objectForKey:(无论如何,它们在iOS 6中都是这样做的).还要为NSMutableArrayNSMutableDictionary分别添加- (void)setObject:(id)obj atIndexedSubscript:(NSUInteger)index- (void)setObject:(id)obj atIndexedSubscript:(NSUInteger)index的类别方法,如果该对象不存在,则仅添加该对象,如果该对象不存在,则将其替换.

EDIT (2 months later now iOS 6 is public). You can definitely use categories to get around the SDK requirements of the new objective-c literal syntax. Add categories on NSArray and NSDictionary for - (id)objectAtIndexedSubscript:(NSUInteger)idx and - (id)objectForKeyedSubscript:(id)key respectively that just return objectAtIndex: and objectForKey: (that is what they do anyway in iOS 6). Also for NSMutableArray and NSMutableDictionary add category methods for - (void)setObject:(id)obj atIndexedSubscript:(NSUInteger)index and - (void)setObject:(id)obj atIndexedSubscript:(NSUInteger)index respectively that simply add the object if it doesn't already exist, and replace it if it does.

一个收获:YESNO的定义在iOS 6中进行了更改,以适应NSNumber的布尔文字.因此,您需要执行以下操作:

One catch: The definitions of YES and NO changed in iOS 6 to accommodate boolean literals for NSNumber. So you need to do the following:

#if __has_feature(objc_bool)
#undef YES //Before it was (BOOL)1
#undef NO //Before it was (BOOL)0

#define YES __objc_yes
#define NO __objc_no
#endif

原因是在新语法中已经有@( ... )语法的定义(框式表达式),而旧定义将解析为@(BOOL)1,这是一个错误.

The reason is that in the new syntax already has a definition for the @( ... ) syntax (boxed expressions) and the old definition would resolve to @(BOOL)1 which is an error.

这篇关于LLVM 4.0可以在Xcode 4.3中使用吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆