我似乎在目标 c 中访问和比较 NSMutableArrays 中的对象时遇到困难。我很新,所以在解释时,一些代码会很好。我有一个字符类和一个字符类。代码如下所示:
@implementation character
@synthesize IDE, name;
- (void) dealloc {
[text release];
[super dealloc];
}
@implementation characterfound
@synthesize IDE;
- (void) dealloc {
[text release];
[super dealloc];
}
我有两个数组,其中填充了名称和 ID。如果我只想比较 id 来构建一个新数组或用它做其他事情。我该怎么做呢。
例如
**特点[]** 姓名:乔·史密斯 IDE:ik321 姓名:詹姆斯·史密斯 IDE:ik32a **找到的字符[]** IDE:2343k IDE:ik32a
所以当我比较两者时,会找到id,我可以把名字放在另一个数组中。或者输出..
我会尝试重新提出我的问题,并更具体地回答顺便说一句。我有两个类字符类
@interface character : NSObject {
// attributes
NSInteger type;
NSInteger rep1, rep2, rep3, rep4, rep5;
NSString *name;
NSString *IDE;
}
和 characterfound 类
@interface characterfound : NSObject {
// attributes
//NSInteger IDE;
NSInteger type;
NSString *IDE;
}
当我解析 xml 文件时,它会遇到不同的标签等并相应地填充我的字符类
例如
foundcharacter中还有一些其他xml,如下所示:
所以我的第一个数组将填充字符对象,包括它的属性,第二个数组 foundcharacter 也将填充。 characterarray = [character1 name="johnson" id="jfja33", character2 name="smith" id="sdfae23"]
characterfoundarray [characterfound ide ="jfja33 , characterfound2 ide="jap234" ]; 所以我的数组正在填充对象及其属性,我想比较属性(如果可能的话)并创建一个输出。