我正试图从swift向目标C发送和接收值。我工作过如何发送,即使我不确定它是否是最有效的编码。我真的坚持将价值回归迅速。我相信它是一种类方法。
这是我目前的代码 我想我可以使用字典
返回多个值我尝试过这样的代码
let Instance = pitchShift.pitchMethod(CGFloat(sendOne), sendTwo, indata)
let returnValue = Instance() -> (Int: returnMe)
但无济于事。 感谢阅读和可能的帮助
// MainWindowController.swift
import Cocoa
class MainWindowController: NSWindowController {
override func windowDidLoad() {
super.windowDidLoad()
let sendOne = 1.4
let sendTwo:CLong = 4096
let myArray:[Float] = [0.1,0.2,0.3,0.4,0.5]
let indata:NSArray = myArray as NSArray
pitchShift.pitchMethod(CGFloat(sendOne), sendTwo, indata)
print("\n out the other side")
}//End of Overide
}//END OF THE WORLD
这是桥接标题
//PitchShift-Bridging-Header.h
#import "PitchShift.h"
这是标题
// pitchShift.h
#import <Foundation/Foundation.h>
@interface pitchShift : NSObject
@property (strong, nonatomic) id pitchProperty;
+ (void) pitchMethod: (CGFloat) sendOne :(long) sendTwo : indata;
@end
这是类方法我想将“returnMe”返回到swift
//PitchShift.m
#import "PitchShift.h"
#include <stdio.h>
@implementation pitchShift
// classmethod
+ (void) pitchMethod:(CGFloat) sendOne : (NSInteger) sendTwo : (NSArray*)pindata {
/* main processing loop */
for (long i = 0; i < 4; i++){
NSArray *inDataArray = pindata;
NSNumber *inNSnumber = inDataArray[i];
float inDataFloat = [inNSnumber floatValue];;
printf("\n %f %f %li %li",inDataFloat,sendOne,i,sendTwo);
}//eo for
long returnMe = 7;
printf("\n returnMe = %li",returnMe);
}//End of the World
@end