我使用2个sqlite db文件。
1)填写来自sqlite db。
的项目@property (nonatomic, strong) NSMutableArray *items;
.......
FMResultSet *results = [db1 executeQuery:query];
while ([results next]) {
Book *book = [[Book alloc] init];
book.content = [results stringForColumn:@"Zcontent"];
book.title = [results stringForColumn:@"Ztitle"];
book.idx = [results intForColumn:@"Zidx"];
book.highlight_YN = NO;
[items addObject:book];
[book release];
}
2)之后,从其他-B-sqlite db。
中选择项目FMDatabase *userDB = [FMDatabase databaseWithPath:userfmdbPath];
NSString *query2 = [NSString stringWithFormat:@"SELECT zidx, highlight_YN FROM zHighlight where zbook = %d and zchapter = %d order by zidx ", pBook,pChapter];
FMResultSet *userresults = [userDB executeQuery:query2];
3)问题:我想修改highlight_YN
与userresults
- results
相比的项目的属性(zidx
)。
如何修改NSMutableArray
属性?
答案 0 :(得分:1)
您可以遍历items
数组并搜索对象。
for ( Book *book in items ) {
if( book.idx == [userresults intForColumn:@"zidx"] )
{
book.highlight_YN = [userresults boolForColumn:@"highlight_YN"];
break;
}
}