プロジェクトの別のクラスで使用できるデータファイルに構造体を作成しようとしています。私はエラーメッセージ "リンカコマンドは、終了コード1で失敗しました(呼び出しを見るために-vを使用します)。さらに、data.mファイルの私のメインメソッドでアーキテクチャx86_64の1重複シンボルがあることを私に伝えます。ここではソリューションページを開き、.mファイルのインポートがないこと、ビットコードを有効にするをNoに変更する、重複するファイルがないことを確認する、その他のリンカーフラグから-ObjCを削除するなど、すべてのソリューションを試しました。私はそれがどのように私は、構造体を宣言していますと間違って何かかもしれないと思うので、Objective-Cのにかなり新しいです。xCodeで "終了コード1(リンカーコマンドは呼び出しを見るために-vを使用)"で失敗しました
//data.h
#import <Foundation/Foundation.h>
@interface data : NSObject
typedef struct Cards
{
__unsafe_unretained NSString* Name;
__unsafe_unretained NSString* Images;
__unsafe_unretained NSString* Phone;
__unsafe_unretained NSMutableAttributedString* Website;
int Restaurant_id;
}Card;
@property Card* ExampleCard;
@end
//data.m
#import <Foundation/Foundation.h>
#import "data.h"
@implementation data
@synthesize ExampleCard;
@end
int main()
{
Card Salernos;
Card *ExampleCard; // = malloc(sizeof(struct Cards) * 16);
/* Salernos Restaurant specification */
Salernos.Name = @"P. Salerno's III";
Salernos.Images = @"Salernos";
Salernos.Phone = @"(609) 245-0474";
Salernos.Website = [[NSMutableAttributedString alloc]initWithString:@"Order Now!"];//yourTextView.attributedText = str;
[Salernos.Website addAttribute: NSLinkAttributeName value: @"https://www.grubhub.com/restaurant/p-salernos-iii-1292-lower-ferry-rd-ewing/313805?utm_source=google&utm_medium=organic&utm_campaign=place%20action%20link" range: NSMakeRange(0, Salernos.Website.length)];
ExampleCard[0] = Salernos;
return 0;
}
私は
#import "data.h"
...
data *Data;
を置く構造体からのデータを使用したいクラスで
私が使用したいデータは、Data.ExampleCard [i]として記述されます。ここで、iはデータを取得するforループの一部です。
が、それはこれまでのところ、エラーメッセージを処分しました。他のクラスのデータ*データラインを変更する必要がありますか? –
あなたはallocしてinitする必要があります! – Lion