我正在开发一个通用的iOS应用程序,我想在调试时看到日志中的原始SQL.这篇博客文章中有一些关于如何为iOS Core Data开发启用原始SQL日志记录的信息.给出的示例适用于XCode 3,我不清楚如何在XCode 4中启用它.
我尝试了"产品" - >"编辑方案",并将" -com.apple.CoreData.SQLDebug 1 " 添加到"启动时传递的参数",但我仍然没有在日志中看到任何输出.不确定我是在寻找错误的地方还是仅仅错误地传递了参数.
我正在实现tableview,我想在tableview的部分显示类名,我试图从使用核心数据实现的数据库中获取类值,我想在classname上使用group by子句获取数据这是我的代码
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication]delegate];
//create managed object context
NSManagedObjectContext *context = [appDelegate managedObjectContext];
NSFetchRequest* fetch = [NSFetchRequest fetchRequestWithEntityName:@"Boking_Detail"];
NSEntityDescription* entity = [NSEntityDescription entityForName:@"Boking_Detail"
inManagedObjectContext:context];
NSAttributeDescription* clsName = [entity.attributesByName objectForKey:@"classname"];
NSAttributeDescription* clsDate = [entity.attributesByName objectForKey:@"classdate"];
NSAttributeDescription* startTime = [entity.attributesByName objectForKey:@"starttime"];
NSAttributeDescription* endTime = [entity.attributesByName objectForKey:@"endtime"];
NSExpressionDescription *expressionDescription = [[NSExpressionDescription alloc] init];
[expressionDescription setName: @"count"];
// [expressionDescription setExpression: countExpression];
[expressionDescription setExpressionResultType: NSInteger32AttributeType];
[fetch setPropertiesToFetch:[NSArray arrayWithObjects:clsName,clsDate,startTime,endTime, expressionDescription, nil]];
[fetch setPropertiesToGroupBy:[NSArray arrayWithObject:clsName]];
[fetch setResultType:NSDictionaryResultType];
NSError* error = nil;
NSArray *results …Run Code Online (Sandbox Code Playgroud)