我正在寻找在Mac上构建一个带有后端守护程序进程的Cocoa应用程序(可能只是一个大多数无头的Cocoa应用程序),以及在本地运行的0个或更多"客户端"应用程序(尽管我可能会这样做)也支持远程客户端;远程客户端只能是其他Mac或iPhone OS设备).
传递的数据将是相当简单的,大多数只是文本和命令(我猜想无论如何都可以表示为文本),也可能是偶尔的小文件(可能是图像).
我已经看了几个方法,但是我不确定哪个方法对于手头的任务来说"最好".我考虑过的事情:
NSConnection:我无法弄清楚这个类甚至做了什么,但我已经在一些IPC搜索结果中读到了它我确信有些东西我不见了,但我很惊讶地发现这个话题缺乏资源.
使用时连接到"www.google.com"时出错NSConnection.
我找不到原因.任何帮助将不胜感激.
NSString *urkString = @"www.google.com";
NSURL *url = [NSURL URLWithString:urkString];
NSURLRequest *request = [NSURLRequest requestWithURL:url
cachePolicy:NSURLRequestReturnCacheDataElseLoad timeoutInterval:60];
_connection = [[NSURLConnection alloc]initWithRequest:request delegate:self];
if(_connection)
{
_receivedData = [[NSMutableData alloc] init];
}
else
{
UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"Error" message:@"Cannot connect to the Web site." delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:nil, nil];
[alertView show];
[alertView release];
}
Run Code Online (Sandbox Code Playgroud)
但它称之为这种方法.错误是:
Error Domain=NSURLErrorDomain Code=-1002 "unsupported URL" UserInfo=0x4c9feb0 {NSErrorFailingURLStringKey=www.google.com, NSErrorFailingURLKey=www.google.com, NSLocalizedDescription=unsupported URL, NSUnderlyingError=0x4c9fdf0 "unsupported URL"}
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
_endSystemDate = [self getSystemDate];
_receivedData …Run Code Online (Sandbox Code Playgroud) 我正在使用DO for IPC.我使用以下代码.它的工作正常在10.6和10.7但在10.8模具上甚至两种应用都是理想的.
// HELPER
NSConnection *connection =[NSConnection new];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(connectionDidDie:)
name:NSConnectionDidDieNotification
object:nil];
[connection setRootObject:syncManager];
if ([connection registerName:SYNC_SERVER_NAME] == NO){
NSLog(@"Error registering server");
}
- (void)connectionDidDie:(NSNotification *)aNotification{
NSConnection *deadConnection = [aNotification object];
id currentClient = [self.clientsList objectAtIndex:0];
NS_DURING
if([currentClient respondsToSelector:@selector(connectionForProxy)]) {
if(deadConnection == [currentClient connectionForProxy]){
// remove proxy with dead connection
[clientsList removeObjectAtIndex:0];
NSLog(@"Removed client from client list.");
}
}
NS_HANDLER
[self.clientsList removeObjectAtIndex:0];
NS_ENDHANDLER
}
Run Code Online (Sandbox Code Playgroud)
// UI App
// ------
self.server = [NSConnection rootProxyForConnectionWithRegisteredName:SYNC_SERVER_NAME host:nil];
if(nil != self.server){ …Run Code Online (Sandbox Code Playgroud) 我正在尝试让Objective C++分布式对象模型在iOS和OSX设备之间工作.使用WiFi,几乎一切都很好; 然而,iOS 7 Apple引入了"includesPeerToPeer"属性,该属性应该使用Blutooth在Bonjour上发布NSNetService.我设置了这样的属性:
self.netService.includesPeerToPeer = YES;
Run Code Online (Sandbox Code Playgroud)
在打电话之前
[self.netService publish];
Run Code Online (Sandbox Code Playgroud)
这在MAC和运行iOS 7的任何iOS设备之间运行良好(给定,MAC和设备之前配对).然而,这些设备并没有通过Blutooth发现自己.
我想知道,我是否错过了什么,或者是否有任何胶水,为什么这不起作用.
我正在尝试在 OSX 应用程序和命令行工具之间创建连接以处理分布式对象。
连接在命令行工具中注册是这样的
[NSConnection serviceConnectionWithName:@"server" rootObject:extManager];
Run Code Online (Sandbox Code Playgroud)
并尝试从应用程序连接到注册的连接对象,如下所示
self.serverConnection = [NSConnection connectionWithRegisteredName:@"server" host:nil];
Run Code Online (Sandbox Code Playgroud)
当应用程序没有被沙盒化时,连接就建立了。当应用程序被沙盒化时,connectionWithRegisteredName返回 nil。
我已尝试向权利添加密钥和值,并使用团队证书对工具和应用程序进行签名,但它不起作用
<key>com.apple.security.application-groups</key>
<array>
<string><TEAM ID>.AppSuite</string>
</array>
Run Code Online (Sandbox Code Playgroud)
在沙盒化时,我该怎么做才能使连接正常工作?
nsconnection ×5
cocoa ×2
macos ×2
app-store ×1
entitlements ×1
ios ×1
ipc ×1
networking ×1
sandbox ×1
sockets ×1