我有这个代码:
-(void)didEditCard:(NSMutableArray*)theArray {
// Create a new instance of the entity managed by the fetched results controller.
NSManagedObject *newManagedObject = [[self fetchedResultsController] objectAtIndexPath:theSIndePath];
// If appropriate, configure the new managed object.
[newManagedObject setValue:[theArray objectAtIndex:0] forKey:@"frontCard"];
[newManagedObject setValue:[theArray objectAtIndex:1] forKey:@"flipCard"];
}
Run Code Online (Sandbox Code Playgroud)
我知道在表视图中触摸了哪个托管对象.如果玩家触摸一个单元格,则会出现一个视图,他可以编辑这些条目.如果他点击完成,那么将调用上述方法.BTW什么都没有.但是,如果我调用setValue,我将不会更新核心数据.
我的目标是:我想更新一个托管对象,该对象应该更新核心数据文件,或者我想从核心数据文件中删除该对象,然后在完全相同的位置添加新对象.
有谁可以帮助我吗?
编辑:
我试过这个:但它不起作用:(它没有得到更新)
-(void)didEditCard:(NSMutableArray*)theArray {
// Create a new instance of the entity managed by the fetched results controller.
NSManagedObject *managedObject = [[self fetchedResultsController] objectAtIndexPath:theSIndePath];
// If appropriate, configure the new managed object.
[managedObject setValue:[theArray objectAtIndex:0] forKey:@"frontCard"];
NSManagedObjectContext …Run Code Online (Sandbox Code Playgroud) 首先我的代码:
- (NSMenu*)sourceList:(PXSourceList*)aSourceList menuForEvent:(NSEvent*)theEvent item:(id)item
{
if ([theEvent type] == NSRightMouseDown || ([theEvent type] == NSLeftMouseDown && ([theEvent modifierFlags] & NSControlKeyMask) == NSControlKeyMask)) {
NSMenu * m = [[NSMenu alloc] init];
if (item != nil) {
NSLog(@"%@",[item title]);
[m addItemWithTitle:[item title] action:@selector(press:) keyEquivalent:@""]; // problem. i want to give "item" as an argument.....
for (NSMenuItem* i in [m itemArray]) {
[i setTarget:self];
}
} else {
[m addItemWithTitle:@"clicked outside" action:nil keyEquivalent:@""];
}
return [m autorelease];
}
return nil;
}
-(void) …Run Code Online (Sandbox Code Playgroud) 我想移动屏幕周围屏幕上触摸的任何b2体.我听说过关于鼠标关节的一些事情..
我发现:http://iphonedev.net/2009/08/05/how-to-grab-a-sprite-with-cocos2d-and-box2d/
但是如果我只是将ccTouch方法复制到一个新项目中(当然也是标题中的变量),我只是给了我很多错误.例如world-> Query < - 没有找到成员
可能会有人制作一个tut /一个新项目并将其上传到此处.或者,还有更好的方法?
我有这个:
CGPoint vel = hudLayer.rightJoystick.velocity;
CCBullet* sp = [CCBullet spriteWithFile:@"green.png"];
sp.position = player.position;
[self addChild:sp z:-10];
vel = ccpMult(ccpNormalize(vel), 300);
sp.rotation = //how to get the rotation out of the velocity?
Run Code Online (Sandbox Code Playgroud)
有帮助吗?
我有一个NSArray和许多NSDictionaries.我正在使用for它循环:
for (int i = 0; i < [myArray count]; i++) {
}
Run Code Online (Sandbox Code Playgroud)
现在我想对数组的每个第二个对象做一些事情.假设数组的计数为5.它将对第2,第4和第5个对象执行某些操作.
我怎样才能做到这一点?
for (int i = 0; i < [myArray count]; i++) {
if //check if it is the second object
}
Run Code Online (Sandbox Code Playgroud)
编辑:每个第二个对象和最后一个对象,如果一个将保留..