在Xcode 6中关闭指定的初始化程序检查 [英] Turn off designated initializer checking in Xcode 6

查看:145
本文介绍了在Xcode 6中关闭指定的初始化程序检查的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了编译错误:

error: convenience initializer missing a 'self' call to another initializer [-Werror,-Wobjc-designated-initializers]

经过编译检查的指定初始值设定项可能是一件好事,但是如果我现在不想处理该问题,我该如何关闭呢?

Compile-checked designated initializers might be a good thing, but if I don't want deal with that right now, how can I turn this off?

推荐答案

方法1

在您的项目中:

Method 1

In your project:

  1. 编辑目标的构建设置(⌘-1,选择项目,或参阅
  2. 添加-Wno-objc-designated-initializers.
  1. Edit the build settings for your target (⌘-1, select project, or cf. Apple docs).
  2. Search for "Other warning flags".
  3. Add -Wno-objc-designated-initializers.

您还可以在每个文件的基础上或使用叮当声诊断推送和弹出窗口来对此和-Wobjc-designated-initializers进行某种组合(请参阅@bandejapaisa的方法3"

You can also do some combination of this and -Wobjc-designated-initializers on a per file basis or with clang diagnostic pushes and pops (cf. @bandejapaisa's "Method 3" answer below).

此方法使您可以在Xcode 5和Xcode 5之间来回切换. 6,并提醒您修复指定的初始值设定项.

This method allows you to switch back and forth between Xcode 5 & 6, and also provides you a reminder to fix the designated initializer stuff.

对于iOS开发,请将其放在您的.pch(预编译头文件)文件中:

For iOS development, put this in your .pch (precompiled header) file:

#ifdef __IPHONE_8_0
    // suppress these errors until we are ready to handle them
    #pragma message "Ignoring designated initializer warnings"
    #pragma clang diagnostic ignored "-Wobjc-designated-initializers"
#else
    // temporarily define an empty NS_DESIGNATED_INITIALIZER so we can use now,
    // will be ready for iOS8 SDK
    #define NS_DESIGNATED_INITIALIZER
#endif

对于OS X 10.10,__IPHONE_8_0模拟__MAC_10_10.

The analog to __IPHONE_8_0 for OS X 10.10 is __MAC_10_10.

如果您对这些消息为何存在感兴趣,可以查看此SO答案 或这些 Apple文档.

If you are interested in why these messages exist, you can check out this SO answer or these Apple docs.

这篇关于在Xcode 6中关闭指定的初始化程序检查的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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