【问题标题】:ambiguous "use of unresolved identifier" error?模棱两可的“使用未解析的标识符”错误?
【发布时间】:2015-08-25 06:53:56
【问题描述】:

我遇到了这种使用未解决标识符的错误,这对我来说非常模糊,它出现在以下行:

但是“LUTToNSDataConverter”在以下文件中初始化:

//
//  LUTToNSDataConverter.h
//  imglyKit
//
//  Created by Carsten Przyluczky on 29/01/15.
//  Copyright (c) 2015 9elements GmbH. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface LUTToNSDataConverter : NSObject

+ (nullable NSData *)colorCubeDataFromLUTNamed:(nonnull NSString *)name interpolatedWithIdentityLUTNamed:(nonnull NSString *)identityName withIntensity:(float)intensity cacheIdentityLUT:(BOOL)shouldCache;

/*
 This method reads an LUT image and converts it to a cube color space representation.
 The resulting data can be used to feed an CIColorCube filter, so that the transformation 
 realised by the LUT is applied with a core image standard filter 
 */
+ (nullable NSData *)colorCubeDataFromLUT:(nonnull NSString *)name;

@end

我可以补充一下,当我将整个文件夹从 Pods 项目目标拖到我的常规项目目标时,这个变量变得“未解析”,所以 Xcode 可以识别它。我该如何解决这个问题?

【问题讨论】:

    标签: ios swift variables xcode6 uiimagepickercontroller


    【解决方案1】:

    编译器不知道LUTToNSDataConverter 是什么?所以请像这样使用

    1. 首先在你的当前视图控制器中导入这个文件

    2. 然后在类上调用方法,像这样在类名后面放() LUTToNSDataConverter()。

    LUTToNSDataConverter(). colorCubeDataFromLUTNamed()// Pass your arguments here
    

    希望对你有帮助。

    【讨论】:

      【解决方案2】:

      您需要添加一个 Bridging-header,因为您使用的是 Objective-C 类:

      1. 向您的项目添加一个名为 [MyProjectName]-Bridging-Header.h 的头文件。这将是您导入任何您希望 Swift 代码访问的任何 Objective-C 代码的单个头文件。

      2. 在您的项目构建设置中,找到 Swift Compiler – Code Generation,然后在 Objective-C Bridging Header 旁边添加项目根文件夹中桥接头文件的路径。因此,如果文件位于项目根文件夹中,则可以通过 MyProject/MyProject-Bridging-Header.h 或简单地通过 MyProject-Bridging-Header.h。

      之后,您可以像这样将导入添加到该文件中:

      #import "YourHFile.h"
      

      (source)

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-03-17
        • 1970-01-01
        相关资源
        最近更新 更多