我在这里遇到了某种结构问题,因为我不确定我正在尝试做的事情是否可行:
我有三个自定义类,它们代表从机器代码翻译的指令类型。每个类都具有指令功能和操作数等属性。它们在第三个 VC 中被初始化并转换为实例并放入 NSMutableArray,我成功地将 NSMutableArray 移动到第四个 VC。现在,我需要遍历数组的每个对象(不知道它是哪种类型的类)并访问它的“指令”属性(即 NSString)。那可能吗?
类之一的声明示例:
@interface iInstruction : NSObject
@property (strong) NSString *opCode;
@property (strong) NSString *rs;
@property (strong) NSString *rt;
@property (strong) NSString *immediate;
@property (strong) NSMutableString *instruction;
- (id) initWithBinary: (NSString *) binaryInstruction;
如何创建实例并移动到第四个 VC:
iInstruction *NewI = [[iInstruction alloc] initWithBinary:binary32Bits];
[TranslatedCode appendFormat:@"%@\n", NewI.instruction];
[instructions addObject: NewI];
disassembledCode.text = TranslatedCode;
FourthViewController *theVCMover = [self.tabBarController.viewControllers objectAtIndex:3];
theVCMover.instructionsInfo = instructions;
我正在尝试做的失败尝试:
for (NSUInteger i=0; i < [instructionsInfo count]; i++) { //instructionsInfo is a property of the fourth VC that I use to move the main array from the third VC
NSString *function = [instructionsInfo objectAtIndex:i].instruction; //Of course it says property not found because it only receives the NSMutableArray at runtime
if (function isEqualToString:@"andi") {
}