![](/img/trans.png)
[英]Objective-C: Why I am getting exception trying to remove object from nsmutable array?
[英]Why am I getting a type conflict warning on my enum in Objective-C?
這是我的Constants.h:
@import Foundation;
typedef NS_ENUM(NSUInteger, BarcodeType) {
kNormalBarcode,
kNoBarcode,
kGenericBarcode,
kInvalidBarcode,
kComicBarcode
};
@interface Constants : NSObject
@end
這是一個使用它的函數:
。H:
@interface Helper : NSObject
- (BarcodeType)barcodeType:(NSString *)barcode;
.M:
#import "Constants.h"
...
- (BarcodeType)barcodeType:(NSString *)barcode
{
return kInvalidBarcode;
}
為什么我的功能收到此警告,我需要進行哪些更改以解決此問題?
Conflicting return type in implementation of 'getBarcodeType:': 'id' vs 'BarcodeType' (aka 'enum BarcodeType')
這段代碼似乎可以與舊版本的Xcode一起正常工作。
謝謝!
檢查您的.h文件。 我的猜測是您對方法的聲明使用id
,它與返回BarcodeType
類型的.m文件中的定義沖突。 NSEnum值不是對象,因此id
無效。 您將需要更正聲明,以便返回類型與實現匹配。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.