- (IBAction)EnterButtonPressed:(id)sender {
Sqlite *sqlite = [[Sqlite alloc] init];
NSArray *paths =NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *writableDBPath = [documentsDirectory stringByAppendingPathComponent:@"test.sqlite"];
if (![sqlite open:writableDBPath])
return;
NSArray *query = [sqlite executeQuery:@"SELECT AccessCode FROM UserAccess"];
NSLog(@"%@",query);
我得到的输出为:{ ( AccessCode = ABCD; ) }
我想要的地方如下:abcd
我正在使用来自http://th30z.netsons.org/2008/11/objective-c-sqlite-wrapper/
的包装器请帮忙。
答案 0 :(得分:0)
输出正确,示例清楚地显示了它:
NSArray *results = [sqlite executeQuery:@"SELECT * FROM test;"];
for (NSDictionary *dictionary in results) {
NSLog(@"Row");
for (NSString *key in [dictionary keyEnumerator])
NSLog(@" - %@ %@", key, [dictionary objectForKey:key]);
}
您将获得一个NSDictionaries数组。你可以写例如
NSDictionary *dict = [result at: 0];
NSSTring *itemValue = [dict objectForKey: @"AccessCode"]
NSLog(..., itemValue)
并获得希望的输出。