NSArray *musicArr2 = [musicDao queryCurrdentDataWithandroidId:androidId]; //查询得到的对象数组
MusicObj *musicObj = [[MusicObj alloc] init]; // 要判断的对象,因为这个对象在其他地方获取的,这里只是做个示范
MusicObj *muObj = [[MusicObj alloc] init];
bool isExist = true; // 判断是否存在数组中
if (musicArr2.count >0) {
for (int i = 0; i < musicArr2.count; i++) {
muObj = [musicArr2 objectAtIndex:i];
if ([muObj.musicName isEqualToString:musicObj.musicName]) {
isExist = false;
}
}
NSLog(@"加入对象222=%@,%@,%@",musicObj.musicName,musicObj.androidId,musicObj.musicID);
if (isExist) {
[musicArr addObject:musicObj]; // 把不存在的对象加到数组
}
注:不喜勿喷!!!