我有一个断点设置,想要打印我的UITextField的超级视图.我键入po myTextField.superview但我收到以下错误:
error: instance method 'undoManager' has incompatible result types in different translation units ('id' vs. 'NSUndoManager *')
note: instance method 'undoManager' also declared here
error: 1 errors parsing expression
Run Code Online (Sandbox Code Playgroud)
这意味着什么,我如何打印我的超级视图?我找到了一个链接,在代码中提供了一个简洁的解决方法:http://openradar.io/15890965 ,但我想要一个更好的解决方案.
哎呀,对不起这么长的头衔.
我有一个托管对象上下文,我存储从两个不同位置派生的歌曲.我从手机上的持久存储中获取了一些歌曲(使用Core Data),我从在线数据库中提取了一些歌曲.这两首歌都属于同一个MananagedObject子类.我想这两个歌曲是在一个单一的情况下,因为我想他们两个出现在与NSFetchedResultsController连接的表视图.
当我想保存其中一首歌时会出现问题.我不想将从在线数据库中提取的所有歌曲保存到手机中.我只想保存单曲,所以简单的[moc save]不起作用.另一个问题是,在我保存单曲之后,我仍然希望从在线播放的歌曲在上下文中(但是再次,不保存).我相信我有几个不同的选择:
1)是否可以将NSFetchedResults控制器连接到多个上下文?
2)我可以将从在线数据库中提取的所有歌曲移动到单独的临时上下文中,保存在原始上下文中,然后将所有歌曲移回.(请参阅:如何将NSManagedObject从一个上下文复制或移动到另一个上下文?)
3)记住在线歌曲的所有键值对,从上下文中删除在线歌曲,保存原始上下文,根据保存的键值对将所有在线歌曲插回到原始上下文中.
4)我是一个巨大的n00b,我更容易丢失一些东西.
谢谢!
core-data nsfetchedresultscontroller nsmanagedobject nsmanagedobjectcontext ios
我有一个对象,其属性可能为零.我应该如何在encodeWithCoder(和decodeWithCoder)中实现它?
- (void)encodeWithCoder:(NSCoder *)aCoder
{
[aCoder encodeObject:_duration forKey:kDuration]; //_duration could be nil
}
Run Code Online (Sandbox Code Playgroud) 我有一个UIDocument名字叫“老”。我对其进行了一些更改,并希望以“ New”的名称重新保存它。“旧”的内容不应更改。这是我失败的尝试:
首先,将尚未保存的“旧”文档复制到“新”文件位置。将“旧”文档保存到“新”文件位置。从理论上讲,由于“旧”文档从未保存到文件系统中的URL,因此它仍应处于“旧”状态。“新”文件位置应将“旧”文件的最新更改,因为我们只是将“旧”文件保存到“新”文件位置。
NSFileManager *manager = [NSFileManager defaultManager];
NSURL *newFileLocation = [documentDirectoryURL URLByAppendingPathComponent:[NSString stringWithFormat:@"%@.%@", document.title, DOCUMENT_EXTENSION]];
NSURL *oldFileLocationCopy = document.fileURL.copy;
NSError *error;
BOOL copySuccess = [manager copyItemAtURL:oldFileLocationCopy toURL:newFileLocation error:&error];
if (! copySuccess)
{
NSLog(@"File not successfully copied.");
return;
}
[document saveToURL:newFileLocation forSaveOperation:UIDocumentSaveForOverwriting completionHandler:^(BOOL success)
{
if (success)
{
handler();
}
else
{
NSLog(@"New file rename not saved.");
}
}];
Run Code Online (Sandbox Code Playgroud)
该代码的结果只是一个简单的重命名操作。“旧”消失,“新”具有新保存的文档的内容。
我觉得这应该很容易,但是我还没有在SO上找到任何类似的问题。提前致谢!
我想跳转到XCode 5中的文件中的前一个光标位置(使用键盘热键或下拉菜单路径).
这个SO帖子适用于XCode 3:XCode是否有像Visual Studio一样的光标导航堆栈?
但对于XCode 5,我在这里找不到这个功能:http://cloud.github.com/downloads/Machx/Xcode-Keyboard-Shortcuts/Xcode_Shortcuts.pdf,也不在Apple文档中:https:// developer. apple.com/library/ios/documentation/IDEs/Conceptual/xcode_help-command_shortcuts/Introduction/Introduction.html#//apple_ref/doc/uid/TP40010560-CH1-SW1
编辑
对不起我以前不清楚.我不想在文件之间切换.如下面的答案所述,这就是ctrl + cmd + left/right的作用.我想在文件中的光标位置之间切换.例如:
我在MyViewController.m工作.
我在第178行写了一个函数 - (void)doStuff.
在 - (void)doStuff中,我意识到我需要将@property更新为readwrite.
我将MyViewController.m的顶部转到第10行.我添加了行@property(非原子,强,读写)NSMutableArray*myArray;
现在我想回来写完我的 - (void)doStuff方法.到达那里的最佳方式是什么?这是我想说"转到最后一个文本光标位置"的时候.
我试图NSTimer在子线程中触发.我的代码基本上是这样的:
-(void) handleTimer:(NSTimer *)theTimer {
NSLog(@"timer fired");
}
-(void) startMyThread {
// If I put timer in here, right before I start my new thread, it fires.
// [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(handleTimer:) userInfo:nil repeats:NO];
[NSThread detachNewThreadSelector:@selector(run) toTarget:self withObject:nil];
}
// This method is called from inside the new thread
-(void) playNote:(Note *)theNote withTemplate:(NSString *)theTemplate X:(int)x andY:(int)y {
NSLog(@"before timer");
// The timer doesn't fire in here. (But the print statements do.)
[NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(handleTimer:) userInfo:nil repeats:NO];
NSLog(@"after …Run Code Online (Sandbox Code Playgroud) 我正在尝试模糊多个SKNode对象。我这样做的目的是让父母SKEffectNode将CIFilter设置为@"CIGaussianBlur"。像这样:
- (SKEffectNode *)createBlurNode
{
SKEffectNode *blurNode = [[SKEffectNode alloc] init];
blurNode.shouldRasterize = YES;
[blurNode setShouldEnableEffects:NO];
[blurNode setFilter:[CIFilter filterWithName:@"CIGaussianBlur"
keysAndValues:@"inputRadius", @10.0f, nil]];
return blurNode;
}
Run Code Online (Sandbox Code Playgroud)
对于当前在屏幕上显示的一堆节点,这可以正常工作。但是,当我将这些音符彼此隔开(约3000像素)时,模糊不再发生,我得到了一个大黑匣子。无论SKNodes我模糊的是SKShapeNodes还是,都会发生这种情况SKSpriteNodes。这是有此问题的示例项目:Sample Project。(顺便说一句,感谢BobMoff在此处找到的初始版本):
这是快乐的模糊效果(当节点彼此之间的距离小于3000像素时):

悲伤模糊(当节点是多个比3000个像素彼此远离):

更新
只要an SKEffectNode是父项,就会发生此行为。启用效果,模糊等都无关紧要。如果父节点是SKNode,就可以了。即,即使像下面这样创建父模糊节点,您也会得到黑色:
- (SKEffectNode *)createBlurNode
{
SKEffectNode *blurNode = [[SKEffectNode alloc] init];
// blurNode.shouldRasterize = YES;
// [blurNode setShouldEnableEffects:NO];
// [blurNode setFilter:[CIFilter filterWithName:@"CIGaussianBlur" …Run Code Online (Sandbox Code Playgroud) ios ×6
uidocument ×2
xcode ×2
cifilter ×1
copy ×1
core-data ×1
hotkeys ×1
ide ×1
lldb ×1
nscoding ×1
nsthread ×1
nstimer ×1
objective-c ×1
rename ×1
skeffectnode ×1
sprite-kit ×1
xcode5 ×1