Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何访问Objective-C中的Swift扩展?_Ios_Objective C_Swift_Objective C Category - Fatal编程技术网

Ios 如何访问Objective-C中的Swift扩展?

Ios 如何访问Objective-C中的Swift扩展?,ios,objective-c,swift,objective-c-category,Ios,Objective C,Swift,Objective C Category,我正在使用这个框架在Objective-C中实现一个datagrid。有一个扩展名为IndexPath+datagrid.swift,它对datagrid的实现至关重要,但是它是用swift编写的 我正在使用CocoaPods,我有以下导入,但仍然无法访问它 @import GlyuckDataGrid; #import <GlyuckDataGrid/GlyuckDataGrid-Swift.h> 导入GlyuckDataGrid; #进口 E:现在我已经找到了解决方案的答案,

我正在使用这个框架在Objective-C中实现一个datagrid。有一个扩展名为
IndexPath+datagrid.swift
,它对datagrid的实现至关重要,但是它是用swift编写的

我正在使用CocoaPods,我有以下导入,但仍然无法访问它

@import GlyuckDataGrid;
#import <GlyuckDataGrid/GlyuckDataGrid-Swift.h>
导入GlyuckDataGrid; #进口
E:现在我已经找到了解决方案的答案,我想指出我忽略了
indepath
nsindepath
。不要被我搞糊涂了2…

框架使用的是纯Swift类型(
indepath
),而不是它的Objective-C等价物(
nsindepath
)。在您的案例中,解决方案是扩展
nsindepath
以及
indepath
以向Objective-C公开功能:


From.

您的扩展名应标记为public,并且无法在桥接类型上定义扩展名-您检查过吗?@Whakkee将于明天进行检查。谢谢,我还没来得及将其删除,其中一位上级就将其删除了。
public extension NSIndexPath {
    /**
     Returns an index-path object initialized with the indexes of a specific row and column in a data grid view.
     - parameter column: An index number identifying a column in a DataGridView object in a row identified by the row parameter.
     - parameter row:    An index number identifying a row in a DataGridView object.
     - returns: An NSIndexPath object.
     */
    convenience init(forColumn column: Int, row: Int) {
        self.init(item: column, section: row)
    }

    /// An index number identifying a column in a row of a data grid view. (read-only)
    var dataGridColumn: Int {
        return self.index(atPosition: 1)
    }

    /// An index number identifying a row in a data grid view. (read-only)
    var dataGridRow: Int {
        return self.index(atPosition: 0)
    }

    /// An index number for single-item indexPath
    var index: Int {
        return self.index(atPosition: 0)
    }
}