使用NSKeyedArchiver和NSData通过蓝牙发送UIImage(Using NSKeyedArchiver and NSData to send UIImage over bluetooth)
我想知道是否有可能在使用NSKeyedArchiver将其编码为NSMutableData之后通过蓝牙发送UIImage。 这就是我的想法:
NSMutableData *data = [[NSMutableData alloc] init]; NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc] initForWritingWithMutableData:data]; [archiver encodeObject:[UIImage imageNamed:"test.png" forKey:kImageKey]; [archiver finishEncoding];
I was wondering if it is possible to send a UIImage over bluetooth after encoding it into a NSMutableData using NSKeyedArchiver. This is what I had in mind:
NSMutableData *data = [[NSMutableData alloc] init]; NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc] initForWritingWithMutableData:data]; [archiver encodeObject:[UIImage imageNamed:"test.png" forKey:kImageKey]; [archiver finishEncoding];
原文:https://stackoverflow.com/questions/2200999
最满意答案
这是一个错误。 它应该工作,它在许多其他情况下也是如此。 当我尝试它时,我确实看到抛出异常:
org.eclipse.core.runtime.OperationCanceledException at org.codehaus.groovy.eclipse.codeassist.processors.GroovyProposalTypeSearchRequestor.checkCancel(GroovyProposalTypeSearchRequestor.java:356) at org.codehaus.groovy.eclipse.codeassist.processors.GroovyProposalTypeSearchRequestor.processAcceptedPackages(GroovyProposalTypeSearchRequestor.java:618) at org.codehaus.groovy.eclipse.codeassist.processors.PackageCompletionProcessor.generateProposals(PackageCompletionProcessor.java:56) at org.codehaus.groovy.eclipse.codeassist.requestor.GroovyCompletionProposalComputer.computeCompletionProposals(GroovyCompletionProposalComputer.java:162) at org.grails.ide.eclipse.editor.gsp.adapter.CodeCompletionDelegate.codeComplete(CodeCompletionDelegate.java:71) at org.codehaus.jdt.groovy.model.GroovyCompilationUnit.codeComplete(GroovyCompilationUnit.java:598) at org.eclipse.jdt.internal.core.CompilationUnit.codeComplete(CompilationUnit.java:359) at org.eclipse.jst.jsp.ui.internal.contentassist.JSPJavaCompletionProposalComputer.computeJavaCompletionProposals(JSPJavaCompletionProposalComputer.java:237) at org.eclipse.jst.jsp.ui.internal.contentassist.JSPJavaCompletionProposalComputer.computeCompletionProposals(JSPJavaCompletionProposalComputer.java:114) at org.eclipse.wst.sse.ui.internal.contentassist.CompletionProposalComputerDescriptor.computeCompletionProposals(CompletionProposalComputerDescriptor.java:284) at org.eclipse.wst.sse.ui.internal.contentassist.CompletionProposalCategory.computeCompletionProposals(CompletionProposalCategory.java:290) at org.eclipse.wst.sse.ui.contentassist.StructuredContentAssistProcessor.collectProposals(StructuredContentAssistProcessor.java:475) at org.eclipse.wst.sse.ui.contentassist.StructuredContentAssistProcessor.computeCompletionProposals(StructuredContentAssistProcessor.java:254) at org.eclipse.wst.sse.ui.internal.contentassist.CompoundContentAssistProcessor.computeCompletionProposals(CompoundContentAssistProcessor.java:127) at org.eclipse.jface.text.contentassist.ContentAssistant.computeCompletionProposals(ContentAssistant.java:1839) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.computeProposals(CompletionProposalPopup.java:566) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.access$16(CompletionProposalPopup.java:563) at org.eclipse.jface.text.contentassist.CompletionProposalPopup$2.run(CompletionProposalPopup.java:498) ...
我必须看看这里发生了什么。
更新:
提出这个问题: https : //issuetracker.springsource.com/browse/STS-3337
发现问题并推出修复程序。 将在下一个快照构建中提供。
This is a bug. It should be working and it does in many other situations. When I try it, I do see that an exception is being thrown:
org.eclipse.core.runtime.OperationCanceledException at org.codehaus.groovy.eclipse.codeassist.processors.GroovyProposalTypeSearchRequestor.checkCancel(GroovyProposalTypeSearchRequestor.java:356) at org.codehaus.groovy.eclipse.codeassist.processors.GroovyProposalTypeSearchRequestor.processAcceptedPackages(GroovyProposalTypeSearchRequestor.java:618) at org.codehaus.groovy.eclipse.codeassist.processors.PackageCompletionProcessor.generateProposals(PackageCompletionProcessor.java:56) at org.codehaus.groovy.eclipse.codeassist.requestor.GroovyCompletionProposalComputer.computeCompletionProposals(GroovyCompletionProposalComputer.java:162) at org.grails.ide.eclipse.editor.gsp.adapter.CodeCompletionDelegate.codeComplete(CodeCompletionDelegate.java:71) at org.codehaus.jdt.groovy.model.GroovyCompilationUnit.codeComplete(GroovyCompilationUnit.java:598) at org.eclipse.jdt.internal.core.CompilationUnit.codeComplete(CompilationUnit.java:359) at org.eclipse.jst.jsp.ui.internal.contentassist.JSPJavaCompletionProposalComputer.computeJavaCompletionProposals(JSPJavaCompletionProposalComputer.java:237) at org.eclipse.jst.jsp.ui.internal.contentassist.JSPJavaCompletionProposalComputer.computeCompletionProposals(JSPJavaCompletionProposalComputer.java:114) at org.eclipse.wst.sse.ui.internal.contentassist.CompletionProposalComputerDescriptor.computeCompletionProposals(CompletionProposalComputerDescriptor.java:284) at org.eclipse.wst.sse.ui.internal.contentassist.CompletionProposalCategory.computeCompletionProposals(CompletionProposalCategory.java:290) at org.eclipse.wst.sse.ui.contentassist.StructuredContentAssistProcessor.collectProposals(StructuredContentAssistProcessor.java:475) at org.eclipse.wst.sse.ui.contentassist.StructuredContentAssistProcessor.computeCompletionProposals(StructuredContentAssistProcessor.java:254) at org.eclipse.wst.sse.ui.internal.contentassist.CompoundContentAssistProcessor.computeCompletionProposals(CompoundContentAssistProcessor.java:127) at org.eclipse.jface.text.contentassist.ContentAssistant.computeCompletionProposals(ContentAssistant.java:1839) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.computeProposals(CompletionProposalPopup.java:566) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.access$16(CompletionProposalPopup.java:563) at org.eclipse.jface.text.contentassist.CompletionProposalPopup$2.run(CompletionProposalPopup.java:498) ...
I'll have to see what is going on here.
UPDATE:
Raised this issue: https://issuetracker.springsource.com/browse/STS-3337
Found the problem and pushed a fix. Will be available in next snapshot build.
相关问答
更多-
这是一个错误。 它应该工作,它在许多其他情况下也是如此。 当我尝试它时,我确实看到抛出异常: org.eclipse.core.runtime.OperationCanceledException at org.codehaus.groovy.eclipse.codeassist.processors.GroovyProposalTypeSearchRequestor.checkCancel(GroovyProposalTypeSearchRequestor.java:356) at org.codehau ...
-
进入首选项 - >常规 - >编辑器 - >文件关联 在“文件类型”下,找到* .gsp。 在关联的编辑器下,删除GSP编辑器(默认) 按添加,再次添加GSP编辑器,并将其设为默认值。 这对我有用。 What I did is just re-install the GGTS. Then everything works.
-
BootStrap.groovy数据到gsp中的jqGrid(groovy服务器页面)(BootStrap.groovy data into jqGrid in gsp(groovy server pages))[2022-09-04]
我不是jqgrid的专家,但我可以想象你的问题的以下解决方案: $(document).ready(function () { jQuery("#customer_list").jqGrid({ url:'${g.createLink( controller:'customer', action:'jq_customer_list' )}', ... I'm not an expert in jqgrid, but I can imagine the following solu ... -
Spring Tools Suite 3.8.3支持groovy grails吗?(Does Spring Tools Suite 3.8.3 support groovy grails?)[2022-03-23]
STS中的Grails支持(实际上是Groovy / Grails工具套件)以版本3.6.4( 源代码 )结尾。 Grails support in STS (Groovy/Grails Tools Suite, actually) ended in version 3.6.4 (source). -
无法在GGTS中从Groovy控制台保存域类实例(Unable to save a domain class instance from Groovy Console in GGTS)[2024-01-20]
这是Groovy控制台,而不是Grails控制台。 它们使用相同的代码并且看起来相同,但Grails版本挂钩到应用程序中,而Groovy控制台只能访问代码。 要运行控制台,请转到Grails工具| 打开Grails命令提示符并在文本字段中输入console 。 这只是一个GUI包装器,用于grails console运行grails console 。 That's the Groovy console, not the Grails console. They use the same code and ... -
无法为Eclipse安装Groovy / Grails Tool Suite(GGTS)(Unable to install Groovy/Grails Tool Suite (GGTS) for Eclipse)[2022-10-18]
我的错。 3.7.0版本发布后,我忘了将正确(和版本化)的更新站点放入Marketplace条目定义中。 现在已修复。 您应该可以再次从Marketplace安装GGTS。 很抱歉给您带来不便,感谢您在此指点我。 请记住,没有与Eclipse Mars兼容的新GGTS版本。 最后一个版本是3.6.4,与Eclipse 4.4和以前的版本兼容。 My bad. I forgot to put in the right (and versioned) update site into the Marketpla ... -
转至帮助 - >安装新软件。 按“添加”按钮并将“ http://download.eclipse.org/technology/m2e/releases ”粘贴到“位置”字段中。 安装插件。 Go to Help->Install new software. Press "Add" button and paste "http://download.eclipse.org/technology/m2e/releases" into "location" field. Install the plugin. ...
-
您在Package Explorer中。 将GGTS中的View设置更改为Project Explorer。然后您应该能够找到Create View etc选项 选择菜单选项 窗口 - >显示视图 - >项目浏览器 You are in Package Explorer. Change the settings of View in GGTS to Project Explorer.Then you should be able to find Create View etc options Select ...
-
GSP中的大部分逻辑都应该封装在TagLib中,并且可以像其他任何Groovy代码一样轻松地进行调试(至少使用IntelliJ)。 如果你的GSP中有很多scriptlet代码(你不应该这样做),并且你想调试它,那么你不能做比println更多的事情。 另一种可能性是查看为您的GSP生成的Groovy代码的来源。 这可以通过将showSource参数附加到URL来完成,如此处所述。 Most of the logic in your GSPs should be encapsulated in TagLib ...
-
Eclipse GGTS Debugger不会在Groovy代码的断点上停止(Eclipse GGTS Debugger will not stop on breakpoints for Groovy code)[2023-08-25]
脚本运行得很好,但似乎调试器找不到它,因为它缺少脚本中的package指令,因为文件嵌套在包名下。 package MyNamespace def sum = 3 + 5 println "the sum is " + sum The script ran just fine, but it seems the debugger couldn't find it because it was missing the package directive in the script, as the file ...