<分区>
<分区>
if (sqlite3_prepare_v2(dbHandlerPointerNote ,selectQuery , -1, &prepareStmtNote, NULL) == SQLITE_OK) {
while (sqlite3_step(prepareStmtNote) == SQLITE_ROW)
{
NSString *noteName = [[NSString alloc]initWithUTF8String:(const char *) sqlite3_column_text(prepareStmtNote, 0)];
[_notesArray addObject:noteName];
int noteid =sqlite3_column_int(prepareStmtNote, 1);
[_noteidArray addObject:[NSString stringWithFormat:@"%d",noteid]];
NSString *noteDate = [[NSString alloc]initWithUTF8String:(const char *) sqlite3_column_text(prepareStmtNote,2)];
[_notesDate addObject:noteDate];
// arrObj is a mutable arr
}
}
上面是我如何将对象添加到 note_id
数组。
这是我试图获取最后一个对象的方式:
_savedNoteid1=[[_modleClass.noteidArray lastObject]intValue];
但它不能正常工作。如何获取数组中的最后一个对象?
最佳答案
i want to get what the object added to last to the array how is it possible.....
如果你只想访问 NSArray(或 NSMutableArray)实例中的最后一个对象,你可以简单地使用 -lastObject
方法:
id item = [someArray lastObject];
关于ios - 数组中最后添加的对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15308312/