FMDB resultset into dictionary

前端 未结 1 1462
暖寄归人
暖寄归人 2021-02-05 23:36

Is there an easy way to get the FMDB results of an executeQuery:SELECT * ... easily into a dictionary?

FMResultSet *appointmentResults = [[DataClass         


        
相关标签:
1条回答
  • 2021-02-06 00:31

    Yep:

    NSMutableArray *results = [NSMutableArray array];
    
    FMResultSet *appointmentResults = [[DataClass getDB] executeQuery:@"SELECT * FROM Appointments WHERE date = ?",currDateString];
    while ([appointmentResults next]) {
      [results addObject:[appointmentResults resultDictionary]];
    }
    

    -resultDictionary is a built-in method on FMResultSet that will turn the current tuple into an NSDictionary, keyed by column name.

    0 讨论(0)
提交回复
热议问题