我使用Qt 5.3.2开发了一个Mac应用程序.此应用程序处理具有特定扩展名的文件(假设.xyz).
我创建了一个名为XYZ.icns的图标文件,并将其添加到我的应用程序包资源文件夹(MyApp.app/Contents/Resources/XYZ.icns)中.
我还修改了bundle的Info.plist文件以设置文件关联.我添加了这个条目:
<key>CFBundleDocumentTypes</key>
<array>
<!-- Registered file accociation -->
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleTypeName</key>
<string>XYZ</string>
<key>CFBundleTypeExtensions</key>
<array>
<string>xyz</string>
</array>
<key>CFBundleTypeIconFile</key>
<string>XYZ</string>
</dict>
<array>
Run Code Online (Sandbox Code Playgroud)
结果:文件关联工作(双击文件确实打开了我的应用程序)但是,图标没有被替换(仍然显示空白文档图标).
有什么我错过了吗?我查看了其他应用程序的示例,似乎没有什么比我做的更多.
编辑:我做了一些测试.我使用以下命令转储了启动服务数据:
/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Versions/Current/Support/lsregister -dump
Run Code Online (Sandbox Code Playgroud)
在结果中,我可以在文件中找到包含图标信息的文件类型:
...
--------------------------------------------------------------------------------
Container mount state: mounted
bundle id: 105396
...
path: /Applications/MyApp.app
name: MyApp
...
--------------------------------------------------------
claim id: 27628
name: XYZ
rank: Default
reqCaps:
roles: Editor
flags: relative-icon-path doc-type
icon: Contents/Resources/XYZ.icns
bindings: .xyz
--------------------------------------------------------------------------------
...
Run Code Online (Sandbox Code Playgroud)
编辑2:过了一段时间,它终于开始自己工作了.一夜之间,有一个操作系统更新已安装,我还必须关闭计算机(启动服务可能自己刷新了一些东西).我会将我的问题更新为:如何确保启动服务在安装或修改应用程序时刷新关联的文件图标?
我有一个BluetoothSocket与自定义设备通信(双向).有时(当在300字节块中传输8 Mb数据时,这种情况大约发生在4次中),在文件传输过程中,蓝牙停止传输数据.对于大约100-200个数据块(我没有确切的数量),OutputStream.write(byte[], int, int)在每次调用后继续正常返回.没有生成异常.然后,调用OutputStream.write(byte[], int, int)锁.
代码在华硕eee变压器Pad TF101上进行了测试.
我无法访问低OutputStream代码来查看正在发生的事情并进行调试.我的猜测是有一个缓冲区被填满但没有被清空.当缓冲区已满时,write会锁定.
任何人都知道发生了什么?
以下是示例代码:
private class ConnectedThread extends Thread {
private final BluetoothSocket mmSocket;
private final InputStream mmInStream;
private final OutputStream mmOutStream;
public ConnectedThread(BluetoothSocket socket, String socketType) {
mmSocket = socket;
InputStream tmpIn = null;
OutputStream tmpOut = null;
setName( "BT Connected Thread" );
// Get the BluetoothSocket input and output streams
try {
tmpIn = socket.getInputStream();
tmpOut = socket.getOutputStream();
}
catch (IOException …Run Code Online (Sandbox Code Playgroud) 我在签署基于 Qt 的应用程序 un OS X 时遇到问题。我使用的是 Qt 5.3.2。
我已经阅读了包含矛盾信息的各种信息来源。
这是我运行bin/macdeployqtQt 实用程序后应用程序包的内容
SimpleHello.app/
Contents/
Info.plist
PkgInfo
Frameworks/
QtCore.framework/
Resources/
Versions/
5/
QtCore
QtGui.framework/ ... same as Qt core
QtPrintSupport.framework/ ... same as Qt core
QtWidgets.framework/ ... same as Qt core
MacOS/
SimpleHello
PlugIns/ ... some plugins
Resources/
empty.lproj
qt.conf
Run Code Online (Sandbox Code Playgroud)
第一的:
我试过:http : //successfulsoftware.net/2012/08/30/how-to-sign-your-mac-os-x-app-for-gatekeeper/
但是,它似乎在 OS X 10.10 Yosemite 中不再有效
第二:
我能够在没有任何错误的情况下签署整个申请。但是,当运行spctl以验证应用程序的有效性时,我得到
spctl -a -vvvv SimpleHello.app
SimpleHello.app/: rejected
source=obsolete resource envelope …Run Code Online (Sandbox Code Playgroud) 在我支持iOS ARC的代码中,我需要将"self"和其他对象传递给一个块.更具体地讲,我需要与自我和互动ASIHTTPRequest内部对象ASIHTTPRequest的completionBlock.
_operation = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(parseServerReply) object:nil];
_request = [ASIHTTPRequest requestWithURL:@"server.address"];
// ...
[_request setCompletionBlock:^{
[self setResponseString:_request.responseString];
[[MyAppDelegate getQueue] addOperation:_operation];
}];
Run Code Online (Sandbox Code Playgroud)
为了避免以下警告:Capturing "self" strongly in this block will likely lead to a retain cycle.我已经修改了我的代码,以便__weak在此帖子之后添加属性块中使用的对象:修复警告"在此块中强烈捕获[一个对象]可能会导致保留周期"在启用ARC的代码中
结果代码是:
_operation = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(parseServerReply) object:nil];
_request = [ASIHTTPRequest requestWithURL:@"server.address"];
// ...
__weak NSOperation * operation = _operation;
__weak ASIHTTPRequest * request = _request;
__weak typeof(self) * self_ = self;
[request …Run Code Online (Sandbox Code Playgroud)