我正在尝试使用Core Data为iPhone开发一个应用程序,我正在使用一个非常基本的谓词来抓取对象.(即attribute_name == string)
我检查了模型以确保属性名称是正确的,我从这个SO问题中知道RHS的意思是"右手边",它引导我到"字符串"部分.我正在使用创建格式字符串
NSString *predicateString = [NSString stringWithFormat:@"attribute_name==%@", string];
Run Code Online (Sandbox Code Playgroud)
然后去取,我用这个:
NSEntityDescription *entityDescription = [NSEntityDescription entityForName:_entityName inManagedObjectContext:managedObjectContext];
NSFetchRequest *request = [[[NSFetchRequest alloc] init] autorelease];
[request setEntity:entityDescription];
NSPredicate *predicate = [NSPredicate predicateWithFormat:predicateString];
[request setPredicate:predicate];
NSError *error = nil;
NSArray *array = [managedObjectContext executeFetchRequest:request error:&error];
Run Code Online (Sandbox Code Playgroud)
我错过了什么?什么可能导致此错误发生?
谢谢.
我正在尝试使用UIView层执行3D旋转CATransform3DMakeRotation.我很困惑为什么这个简单的例子没有显示透视图,但看起来却被挤压了.我可以在使用时让旋转工作CATransform3DRotate,但我不想旋转,我想旋转到.谢谢.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
UIView *newView = [[UIView alloc] initWithFrame:CGRectMake(100, 100, 100, 100)];
[newView setBackgroundColor:[UIColor orangeColor]];
UILabel *newLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 50, 20)];
[newLabel setText:@"Hello"];
[newView addSubview:newLabel];
[self.window addSubview:newView];
CALayer *layer = newView.layer;
CATransform3D perspective = CATransform3DMakeRotation(1.0, 0, 1, 0);
perspective.m34 = -1 / 500;
layer.anchorPoint = CGPointMake(1.0, 0.5);
layer.zPosition = 99;
layer.transform = perspective;
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
} …Run Code Online (Sandbox Code Playgroud)