我想要一个看起来像这个 player.type.property 的结果,一个例子是 UILabel,self.label.text。.text 是两个类的属性。
我有一个建议是做这样的事情:
player.type = [[MyCustomObject alloc] init];
player.type.property = @"value";
尽管我不太确定如何正确执行此操作,但我尝试过的每种方法都行不通。
这是我尝试过的:
Marketplace.h
#import "Item.h"
@interface Marketplace : NSObject
@property (nonatomic, assign) Item *market;
Item.h
@interface Item : NSObject
@property (nonatomic, assign) int price;
Starter.m
#import "Marketplace.h"
#import "Item.h"
@implementation MainGameDisplay
{
Marketplace *market;
Item *itemName;
}
-(void) executedMethod {
market.itemName = [[market alloc] init];
//2 errors: "Property 'itemName not found on object of type 'MarketPlace'" and "No visible @interface for 'MarketPlace' declares the selector alloc"
market.itemName.price = 5; //"Property 'itemName' not found on object of type 'Marketplace*'"
}