HTML5   发布时间:2022-04-27  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了ios – 使用iPhone检测频率值大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在开发一款可以检测特定声音频率的应用.我的应用程序基于 Pitch Detector.我导入了Pitch Detector示例中的文件,然后我修复了我的代码以接受这个新类.我在这里发布我的代码来解释你的问题:

ViewController.h

#import <UIKit/UIKit.h>

@class RIOInterface;

@interface ViewController : UIViewController {
    BOOL isListening;
    float currentFrequency;
    RIOInterface *rioRef; // HERE I'M GETTING ISSUE
}
- (IBAction)startListenWatermark:(UIButton *)sender;

@property(nonatomic,assign) RIOInterface *rioRef;
@property(nonatomic,assign) float currentFrequency;
@property(assign) BOOL isListening;

#pragma mark Listener Controls
- (void)startListener;
- (void)stopListener;

 - (void)frequencyChangedWithValue:(float)newFrequency;

@end

ViewController.m

@synthesize isListening;
@synthesize rioRef;
@synthesize currentFrequency;

- (IBAction)startListenWatermark:(UIButton *)sender {
    if (isListening) {
        [self stopListener];
    } else {
        [self startListener];
    }
    isListening = !isListening;
}

- (void)startListener {
    [rioRef startListening:self];
}

- (void)stopListener {
    [rioRef stopListening];
}

- (void)frequencyChangedWithValue:(float)newFrequency {
    NSLog(@"FREQUENCY: %f",newFrequency);
}

代码中你可以看到我的问题在哪里,Xcode说:带有assign属性的现有实例变量’rioRef’必须是__unsafe_unretained.如果我删除了给出这个错误的行,那么app就不会调用方法[rioRef startListening:self];和[rioRef stopListening];.

文件RIOInterface.mm中,我在第97行收到另一个错误,Xcode建议我更改它:

RIOInterface* THIS = (RIOInterface *)inRefCon; --> RIOInterface* THIS = (RIOInterface *)CFBridgingRelease(inRefCon);

它给了我283行的另一个错误

callbackStruct.inputProcRefCon = self;

它告诉我这个:从不兼容的类型’RIOInterface * const__strong’分配’void’,所以我查看了网络,我找到了这个解决方案:

callbackStruct.inputProcRefCon = (__bridge void*)self;

我不确定这样做是否正确,我希望你能帮助我解决这个问题,谢谢你的建议.

解决方法

对于第二个和第三个问题,我通过禁用ARC来解决上面提供的代码文件.对于我通过编写此代码解决的第一个问题:

rioRef = [RIOInterface sharedInstance];

大佬总结

以上是大佬教程为你收集整理的ios – 使用iPhone检测频率值全部内容,希望文章能够帮你解决ios – 使用iPhone检测频率值所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: