Iphone 如何修改NSMutableArray属性?
我使用2个sqlite db文件 1) 从sqlite数据库填充项目Iphone 如何修改NSMutableArray属性?,iphone,objective-c,ios,sqlite,nsmutablearray,Iphone,Objective C,Ios,Sqlite,Nsmutablearray,我使用2个sqlite db文件 1) 从sqlite数据库填充项目 @property (nonatomic, strong) NSMutableArray *items; FMDatabase *userDB = [FMDatabase databaseWithPath:userfmdbPath]; NSString *query2 = [NSString stringWithFormat:@"SELECT zidx, highlight_YN FROM zHighlight wh
@property (nonatomic, strong) NSMutableArray *items;
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];
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) 然后,从other-B-sqlite数据库中选择项
@property (nonatomic, strong) NSMutableArray *items;
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) 问题:我想修改结果为userresults
的项目的属性(highlight_YN
),与results
-zidx
相比
如何修改
NSMutableArray
属性 您可以通过项
数组循环搜索对象
for ( Book *book in items ) {
if( book.idx == [userresults intForColumn:@"zidx"] )
{
book.highlight_YN = [userresults boolForColumn:@"highlight_YN"];
break;
}
}
我在上面的代码中没有看到NSMutableArray。事实上,我看到了各种各样的问题(比如
[items addObject:bible]
中的圣经从哪里来?)。请修改您的问题以清理您的代码,并引入一个NSMutableArray。@Michael Dautermann抱歉!我遗漏了一些代码。谢谢我的问题经过编辑^^*