2012-02-22 3 views
10

executeQuery:SELECT * ...의 FMDB 결과를 사전에 쉽게 가져올 수 있습니까?사전에 FMDB 결과 집합

FMResultSet *appointmentResults = [[DataClass getDB] executeQuery:@"SELECT * FROM Appointments WHERE date = ?",currDateString]; 
while ([appointmentResults next]) { 
    //Create dictionary 
    //Add dictionary to array for later use 
} 

사전 키 열 이름과 값을 열 값으로 만들 수있는 방법이 있는지 궁금합니다. 가급적이면 모든 행을 반복 할 필요없이.

답변

27

네 :

NSMutableArray *results = [NSMutableArray array]; 

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

-resultDictionary 컬럼 이름 키잉,있는 NSDictionary로 현재 튜플 바뀔 것이다 FMResultSet에 내장 된 방법이다.

+0

굉장! 이거 어디서 났니? FMDB documentation resultDict를 보면 거기에 없습니다. – Bot

+0

@jostster 그것은'FMResultSet.h'에 있습니다. –

+0

'-resultDict'는 더 이상 사용되지 않으며 대신'-resultDictionary'를 사용하십시오. – lucianf