Re: Acquiring an NSConnection otherwise than by registered name?

2010-09-28 Thread Ken Thomases
On Sep 28, 2010, at 12:24 AM, Oleg Krupnov wrote:

 My question is: is it possible to acquire the connection in another
 way than using a name?

Yes, of course.  Have you looked at the NSConnection class reference, where it 
documents multiple methods for obtaining connection objects?

First of all, your server already has multiple connection objects.  The first 
connection is like a listen socket.  As new clients connect, it accepts those 
and creates a new child NSConnection for each.


 Why I want this: My client process has many threads, and the server
 process must create a thread for each client thread.

Your clients (each thread is a separate client, if you like) should be checking 
in with the server by invoking a specific method on the root proxy.  They 
should be passing some object representing themselves to the server.  On the 
server side, the check-in method will actually receive a proxy for the client's 
object.  This will be an NSDistantObject.  The server can invoke 
-connectionForProxy on it, then -runInNewThread on the connection.

At least, I'm pretty sure that will do what you want.  Another approach would 
be for the server to set a delegate on the main connection and, each time it is 
asked if it's OK to create a new connection for a new client (whether that new 
client is a separate process or just a separate thread), your delegate method 
can invoke -runInNewThread on the new connection.

For a multi-threaded client which wants to have several connections to the same 
server, you may have to jump through a couple of hoops.  NSConnection is pretty 
eager about reusing its instances if they match a new request.  You may need to 
create the connection somewhat manually by creating the ports and then 
explicitly using +connectionWithReceivePort:sendPort: or 
-initWithReceivePort:sendPort:.

Regards,
Ken

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


intermittent sync services crash

2010-09-28 Thread Martin Hewitson
Dear list,

I have a core-data app which syncs its data over mobile-me via sync services. 
Every couple of days or so, the app crashes on different machines. The stack 
trace is pasted below. I'm using essentially the same syncing code I use for 
other apps and I haven't seen this problem before. 

Can anyone provide any hints from the stack trace?

Many thanks,

Martin

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x
Crashed Thread:  3

Application Specific Information:
objc_msgSend() selector name: handleMocChanges:


Thread 0:  Dispatch queue: com.apple.main-thread
0   libSystem.B.dylib   0x7fff81e152fa mach_msg_trap + 10
1   libSystem.B.dylib   0x7fff81e1596d mach_msg + 59
2   com.apple.CoreFoundation0x7fff87fdb3c2 __CFRunLoopRun + 1698
3   com.apple.CoreFoundation0x7fff87fda84f CFRunLoopRunSpecific 
+ 575
4   com.apple.HIToolbox 0x7fff83c6c91a 
RunCurrentEventLoopInMode + 333
5   com.apple.HIToolbox 0x7fff83c6c71f 
ReceiveNextEventCommon + 310
6   com.apple.HIToolbox 0x7fff83c6c5d8 
BlockUntilNextEventMatchingListInMode + 59
7   com.apple.AppKit0x7fff86b7f29e _DPSNextEvent + 708
8   com.apple.AppKit0x7fff86b7ebed -[NSApplication 
nextEventMatchingMask:untilDate:inMode:dequeue:] + 155
9   com.apple.AppKit0x7fff86b448d3 -[NSApplication run] 
+ 395
10  com.apple.AppKit0x7fff86b3d5f8 NSApplicationMain + 
364
11  com.bobsoft.Trips   0x000114dd main + 33 (main.m:14)
12  com.bobsoft.Trips   0x000114b4 start + 52

Thread 1:  Dispatch queue: com.apple.libdispatch-manager
0   libSystem.B.dylib   0x7fff81e2e08a kevent + 10
1   libSystem.B.dylib   0x7fff81e2ff5d _dispatch_mgr_invoke 
+ 154
2   libSystem.B.dylib   0x7fff81e2fc34 
_dispatch_queue_invoke + 185
3   libSystem.B.dylib   0x7fff81e2f75e 
_dispatch_worker_thread2 + 252
4   libSystem.B.dylib   0x7fff81e2f088 _pthread_wqthread + 
353
5   libSystem.B.dylib   0x7fff81e2ef25 start_wqthread + 13

Thread 2:
0   libSystem.B.dylib   0x7fff81e2eeaa __workq_kernreturn + 
10
1   libSystem.B.dylib   0x7fff81e2f2bc _pthread_wqthread + 
917
2   libSystem.B.dylib   0x7fff81e2ef25 start_wqthread + 13

Thread 3 Crashed:
0   libobjc.A.dylib 0x7fff87ec7120 objc_msgSend + 44
1   com.apple.Foundation0x7fff806c484e _nsnote_callback + 
167
2   com.apple.CoreFoundation0x7fff87fe7a90 
__CFXNotificationPost + 1008
3   com.apple.CoreFoundation0x7fff87fd4008 
_CFXNotificationPostNotification + 200
4   com.apple.Foundation0x7fff806bb7b8 
-[NSNotificationCenter postNotificationName:object:userInfo:] + 101
5   com.apple.CoreData  0x7fff887a8843 
-[NSManagedObjectContext(_NSInternalNotificationHandling) 
_postObjectsDidChangeNotificationWithUserInfo:] + 99
6   com.apple.CoreData  0x7fff887df985 
-[NSManagedObjectContext(_NSInternalChangeProcessing) 
_createAndPostChangeNotification:withDeletions:withUpdates:withRefreshes:] + 325
7   com.apple.CoreData  0x7fff8878d3db 
-[NSManagedObjectContext(_NSInternalChangeProcessing) 
_postRefreshedObjectsNotificationAndClearList] + 107
8   com.apple.CoreData  0x7fff8878c506 
-[NSManagedObjectContext(_NSInternalChangeProcessing) _processRecentChanges:] + 
86
9   com.apple.CoreData  0x7fff8878b98b 
-[NSManagedObjectContext executeFetchRequest:error:] + 155
10  com.apple.syncservices  0x7fff84b6865d 
-[ISDPersistentStoreSyncer _pushAllRecordForSyncEntityName:] + 258
11  com.apple.syncservices  0x7fff84b68acd 
-[ISDPersistentStoreSyncer _pushChanges] + 422
12  com.apple.syncservices  0x7fff84b662b9 
-[ISDPersistentStoreSyncer synchronize] + 77
13  com.apple.syncservices  0x7fff84b65986 
-[ISDPersistentStoreSyncer synchronizerThreadMain] + 83
14  com.apple.Foundation0x7fff806c4e8d __NSThread__main__ + 
1429
15  libSystem.B.dylib   0x7fff81e4e456 _pthread_start + 331
16  libSystem.B.dylib   0x7fff81e4e309 thread_start + 13

Thread 3 crashed with X86 Thread State (64-bit):
 rax: 0x  rbx: 0x000100487d60  rcx: 0x000102f24910  
rdx: 0x000102f24970
 rdi: 0x000100487d60  rsi: 0x00010004bd5c  rbp: 0x0001149fb2f0  
rsp: 0x0001149fb298
  r8: 0x   r9: 0x000102f24970  r10: 0x00010109b9b0  
r11: 0x0001004e787b
 r12: 0x0001004a7d70  r13: 0x000102f24970  r14: 

Re: Acquiring an NSConnection otherwise than by registered name?

2010-09-28 Thread Oleg Krupnov
Thanks Ken,

I tried this:

 Your clients (each thread is a separate client, if you like) should be 
 checking in with the server by invoking a specific method on the root proxy.  
 They should be passing some object representing themselves to the server.  On 
 the server side, the check-in method will actually receive a proxy for the 
 client's object.  This will be an NSDistantObject.  The server can invoke 
 -connectionForProxy on it, then -runInNewThread on the connection.

And it seems to work. The client threads no longer block each other
when they need to request the server.

But let me ask a couple of questions, because I don't get how it works
and there might still be a problem in my code:

1. What happens when I call -connectionForProxy on the client proxy
object? Is a new connection created? Or the root vended object's
connection can be reused? In the latter case if I remove that
connection from the main run loop and call -runInNewThread, would the
root object's operation be broken?

2. I tried to launch two client threads simultaneously and pass
different objects to the check-in method, and I see that the
connection returned from -connectionForProxy is the same for the both
threads. Is it a problem? Won't the two threads somehow interfere?
AFAIR connections cannot be shared between different threads.

Here is my code of the check-in method of the root vended object on
the server side:

- (byref NSObjectIServerObject*)createServerObjectForClientObject:(byref
NSObject*)clientObject
{
NSConnection* connection = [(NSDistantObject*)clientObject 
connectionForProxy];
[connection removeRunLoop:[NSRunLoop mainRunLoop]];
[connection runInNewThread];

   // server object is a per-client-thread object on the server
side, not the root vended object
NSObjectIServerObject* serverObject = [[[VendedServerObject alloc]
init] autorelease];
return serverObject;
}

Thanks!

Oleg.

On Tue, Sep 28, 2010 at 9:12 AM, Ken Thomases k...@codeweavers.com wrote:
 On Sep 28, 2010, at 12:24 AM, Oleg Krupnov wrote:

 My question is: is it possible to acquire the connection in another
 way than using a name?

 Yes, of course.  Have you looked at the NSConnection class reference, where 
 it documents multiple methods for obtaining connection objects?

 First of all, your server already has multiple connection objects.  The first 
 connection is like a listen socket.  As new clients connect, it accepts those 
 and creates a new child NSConnection for each.


 Why I want this: My client process has many threads, and the server
 process must create a thread for each client thread.

 Your clients (each thread is a separate client, if you like) should be 
 checking in with the server by invoking a specific method on the root proxy.  
 They should be passing some object representing themselves to the server.  On 
 the server side, the check-in method will actually receive a proxy for the 
 client's object.  This will be an NSDistantObject.  The server can invoke 
 -connectionForProxy on it, then -runInNewThread on the connection.

 At least, I'm pretty sure that will do what you want.  Another approach would 
 be for the server to set a delegate on the main connection and, each time it 
 is asked if it's OK to create a new connection for a new client (whether that 
 new client is a separate process or just a separate thread), your delegate 
 method can invoke -runInNewThread on the new connection.

 For a multi-threaded client which wants to have several connections to the 
 same server, you may have to jump through a couple of hoops.  NSConnection is 
 pretty eager about reusing its instances if they match a new request.  You 
 may need to create the connection somewhat manually by creating the ports and 
 then explicitly using +connectionWithReceivePort:sendPort: or 
 -initWithReceivePort:sendPort:.

 Regards,
 Ken


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Acquiring an NSConnection otherwise than by registered name?

2010-09-28 Thread Ken Thomases
On Sep 28, 2010, at 2:29 AM, Oleg Krupnov wrote:

 Thanks Ken,

You're welcome.  I'm glad to help.


 1. What happens when I call -connectionForProxy on the client proxy
 object? Is a new connection created? Or the root vended object's
 connection can be reused? In the latter case if I remove that
 connection from the main run loop and call -runInNewThread, would the
 root object's operation be broken?

The server creates one NSConnection instance and registers it under a name.  
This connection doesn't actually send data to any client.  It listens for 
connections from clients and, when one connects, creates a new NSConnection 
instance to conduct the communication with that client.  The new NSConnection 
is a child of the original one.  (If you've ever worked with BSD sockets, this 
should be familiar.  The server creates one socket file descriptor with the 
socket() call, calls bind() and listen() on it, and then accept()s new file 
descriptors as connections are made.)

The -connectionForProxy method returns the existing connection being used to 
convey messages to the proxy to its distant real object.  This will be 
different from the NSConnection object the server originally created and 
registered.  It will be one of the child connections.


 2. I tried to launch two client threads simultaneously and pass
 different objects to the check-in method, and I see that the
 connection returned from -connectionForProxy is the same for the both
 threads. Is it a problem? Won't the two threads somehow interfere?

I believe you are being bitten by what I wrote about here:

 On Tue, Sep 28, 2010 at 9:12 AM, Ken Thomases k...@codeweavers.com wrote:
 
 For a multi-threaded client which wants to have several connections to the 
 same server, you may have to jump through a couple of hoops.  NSConnection 
 is pretty eager about reusing its instances if they match a new request.  
 You may need to create the connection somewhat manually by creating the 
 ports and then explicitly using +connectionWithReceivePort:sendPort: or 
 -initWithReceivePort:sendPort:.

Two threads within one process may very well get the same connection to the 
server.  The simple methods for getting the connection (or ignoring the 
connection and just getting the root proxy) just ask by name.  NSConnection 
will realize it already has a connection for that name and reuse it.  So, you 
probably shouldn't use:

+connectionWithRegisteredName:host:
+connectionWithRegisteredName:host:usingNameServer:
+rootProxyForConnectionWithRegisteredName:host:
+rootProxyForConnectionWithRegisteredName:host:usingNameServer:

Instead, you should create two ports of the appropriate type.  If you're using 
Mach ports for communication, then you want NSMachPorts.  If you're using 
sockets for communication, then NSSocketPorts.

You should get the send port from the appropriate port name server.  For 
example, [[NSMachBootstrapServer sharedInstance] portForName:@foo] or 
[[NSSocketPortNameServer sharedInstance] portForName:@foo 
host:@server.example.com].  This send port is still likely to be shared by 
the threads.

So, you should create a separate receive port for each thread.  That's the part 
which ensures that each thread has a separate NSConnection (both on the client 
side and the server side).  For example [NSMachPort port] or [NSSocketPort 
port].

Then, you should create the connection to the server from those two ports, 
using one of:

+connectionWithReceivePort:sendPort:
-initWithReceivePort:sendPort:

Read the documentation for the latter of those to learn about NSConnection 
object re-use/sharing.  Those docs suggest you may be able to get away without 
creating a unique receive port manually.  If you pass nil, it should create one 
for you.  Test to make sure the connection objects your client threads are 
getting are unique from one another.

Then call -rootProxy on the created connection object to get the server's 
vended object.

Cheers,
Ken

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


I want a window's file owner that's not a NSWindowController

2010-09-28 Thread Jonny Taylor
I am trying to understand the right way of dealing with a settings window in 
my application. I have a Camera object that wraps a Firewire video camera. I 
would like to bring up an NSPanel that enables various settings of the camera 
to be modified. I do not need to override any particular behaviours of 
NSWindowController, and it seems to me that logically my Camera object should 
not need to inherit from NSWindowController (the window business is a bit of a 
distraction from the main purpose of the camera class, which is handling 
received frames - and in future I may want more than one such camera-related 
window).

What I thought I could do when I want to bring the settings window up is as 
follows (from within my Camera class):
if (settingsWindowController == NULL)
settingsWindowController = [[NSWindowController alloc] 
initWithWindowNibName:(NSString *)@Camera Settings owner:self];
[settingsWindowController showWindow:self];
(where settingsWindowController is an instance variable of type 
NSWindowController). In the nib file I have set the File's Owner proxy to type 
Camera, and the bindings I have set up for the window all work correctly. 
However [settingsWindowController window] returns nil, and this causes various 
problems. Clearly I am doing something wrong.

Alternatively I can set the File's Owner to type NSWindowController (and not 
specify an owner in my call to initWithWindowNibName). If I do this then the 
window controller is correctly linked to the window (I link up the appropriate 
outlet in IB), but the bindings don't work.

I can't work out whether there is a way I can get my (instance variable-based) 
window controller to work AND bind to the Camera object. I feel this would be 
the tidiest way of doing things (it doesn't make sense to me for Camera to 
inherit from NSWindowController). Is there something extra I need to do to make 
this work, or am I just approaching all this in the wrong way?

I have tried adding an NSWindowController object in the nib (with File's Owner 
still Camera). I can wire that up to the window, but I suspect that's not doing 
anything because I am allocating my own NSWindowController object in the code I 
listed earlier. I wonder if adding the NSWindowController object is the way 
forwards - but if so, how to I go about loading the controller from the nib as 
well as the window itself? I suspect from various other confused postings in 
the archives that initWindowWindowNibName:owner may not be the right thing for 
me to use here.

Hopefully this makes sense - thanks for any suggestions...
Jonny___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


RE: I want a window's file owner that's not a NSWindowController

2010-09-28 Thread Shawn Bakhtiar

NSWindowController is for when you want to have multiple windows of the same 
class (derived from NSWindow), but have different set of callbacks, in 
different Window controllers that you can attach to each identical NSWindow, in 
essence giving you a window class, that can have a different set of callback 
functions.

Question, why not just derive the camera class from NSWindow? There is no 
programmatic need for NSWindowController, as an NSWindow is also an NSResponder 
(can take all input).


 From: j.m.tay...@durham.ac.uk
 Date: Tue, 28 Sep 2010 18:41:40 +0100
 To: cocoa-dev@lists.apple.com
 Subject: I want a window's file owner that's not a NSWindowController
 
 I am trying to understand the right way of dealing with a settings window 
 in my application. I have a Camera object that wraps a Firewire video 
 camera. I would like to bring up an NSPanel that enables various settings of 
 the camera to be modified. I do not need to override any particular 
 behaviours of NSWindowController, and it seems to me that logically my Camera 
 object should not need to inherit from NSWindowController (the window 
 business is a bit of a distraction from the main purpose of the camera class, 
 which is handling received frames - and in future I may want more than one 
 such camera-related window).
 
 What I thought I could do when I want to bring the settings window up is as 
 follows (from within my Camera class):
 if (settingsWindowController == NULL)
   settingsWindowController = [[NSWindowController alloc] 
 initWithWindowNibName:(NSString *)@Camera Settings owner:self];
 [settingsWindowController showWindow:self];
 (where settingsWindowController is an instance variable of type 
 NSWindowController). In the nib file I have set the File's Owner proxy to 
 type Camera, and the bindings I have set up for the window all work 
 correctly. However [settingsWindowController window] returns nil, and this 
 causes various problems. Clearly I am doing something wrong.
 
 Alternatively I can set the File's Owner to type NSWindowController (and not 
 specify an owner in my call to initWithWindowNibName). If I do this then the 
 window controller is correctly linked to the window (I link up the 
 appropriate outlet in IB), but the bindings don't work.
 
 I can't work out whether there is a way I can get my (instance 
 variable-based) window controller to work AND bind to the Camera object. I 
 feel this would be the tidiest way of doing things (it doesn't make sense to 
 me for Camera to inherit from NSWindowController). Is there something extra I 
 need to do to make this work, or am I just approaching all this in the wrong 
 way?
 
 I have tried adding an NSWindowController object in the nib (with File's 
 Owner still Camera). I can wire that up to the window, but I suspect that's 
 not doing anything because I am allocating my own NSWindowController object 
 in the code I listed earlier. I wonder if adding the NSWindowController 
 object is the way forwards - but if so, how to I go about loading the 
 controller from the nib as well as the window itself? I suspect from various 
 other confused postings in the archives that initWindowWindowNibName:owner 
 may not be the right thing for me to use here.
 
 Hopefully this makes sense - thanks for any suggestions...
 Jonny___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/shashaness%40hotmail.com
 
 This email sent to shashan...@hotmail.com
  
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: I want a window's file owner that's not a NSWindowController

2010-09-28 Thread Quincey Morris
On Sep 28, 2010, at 10:41, Jonny Taylor wrote:

 I am trying to understand the right way of dealing with a settings window 
 in my application. I have a Camera object that wraps a Firewire video 
 camera. I would like to bring up an NSPanel that enables various settings of 
 the camera to be modified. I do not need to override any particular 
 behaviours of NSWindowController, and it seems to me that logically my Camera 
 object should not need to inherit from NSWindowController (the window 
 business is a bit of a distraction from the main purpose of the camera class, 
 which is handling received frames - and in future I may want more than one 
 such camera-related window).
 
 What I thought I could do when I want to bring the settings window up is as 
 follows (from within my Camera class):
 if (settingsWindowController == NULL)
   settingsWindowController = [[NSWindowController alloc] 
 initWithWindowNibName:(NSString *)@Camera Settings owner:self];
 [settingsWindowController showWindow:self];
 (where settingsWindowController is an instance variable of type 
 NSWindowController). In the nib file I have set the File's Owner proxy to 
 type Camera, and the bindings I have set up for the window all work 
 correctly. However [settingsWindowController window] returns nil, and this 
 causes various problems. Clearly I am doing something wrong.
 
 Alternatively I can set the File's Owner to type NSWindowController (and not 
 specify an owner in my call to initWithWindowNibName). If I do this then the 
 window controller is correctly linked to the window (I link up the 
 appropriate outlet in IB), but the bindings don't work.
 
 I can't work out whether there is a way I can get my (instance 
 variable-based) window controller to work AND bind to the Camera object. I 
 feel this would be the tidiest way of doing things (it doesn't make sense to 
 me for Camera to inherit from NSWindowController). Is there something extra I 
 need to do to make this work, or am I just approaching all this in the wrong 
 way?
 
 I have tried adding an NSWindowController object in the nib (with File's 
 Owner still Camera). I can wire that up to the window, but I suspect that's 
 not doing anything because I am allocating my own NSWindowController object 
 in the code I listed earlier. I wonder if adding the NSWindowController 
 object is the way forwards - but if so, how to I go about loading the 
 controller from the nib as well as the window itself? I suspect from various 
 other confused postings in the archives that initWindowWindowNibName:owner 
 may not be the right thing for me to use here.

You're kind of mixing up two different tasks here. The Camera object is 
(likely) part of your data model (in the MVC paradigm). A window controller is 
a ... controller. For your settings window, you'll have least heartache if you 
make the NIB's File's Owner a window controller. Window controllers are 
*designed* to be the owners of NIB files.

So, subclass NSWindowController, and add a camera property. (Your Camera 
object can pass its 'self' pointer as a parameter to the window controller 
subclass's init... method.)

Then, to get at Camera properties, objects in the NIB can bind to File's 
Owner.camera.whateverProperty -- instead of File's Owner.whateverProperty as 
you have now.

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Acquiring an NSConnection otherwise than by registered name?

2010-09-28 Thread Oleg Krupnov
Ken,

So, let's assume I create the connection in this way:

NSConnection* connection = [NSConnection connectionWithReceivePort:nil
sendPort:[[NSMachBootstrapServer sharedInstance] portForName:@foo]];

or even

NSConnection* connection = [NSConnection
connectionWithReceivePort:[NSMachPort port] sendPort:[NSMachPort
port]];

Then I vend the object:

[connection setRootObject:serverObject];

And finally launch it in a separate thread:

[connection runInNewThread];

But how do I pass this connection back to client so that I could call
-rootProxy on it? That was actually the original question in the
subject of this mail :)


The other question I've got is how do I exit the newly created thread
when its job is done?

Thanks,

Oleg.

On Tue, Sep 28, 2010 at 11:11 AM, Ken Thomases k...@codeweavers.com wrote:
 On Sep 28, 2010, at 2:29 AM, Oleg Krupnov wrote:

 Thanks Ken,

 You're welcome.  I'm glad to help.


 1. What happens when I call -connectionForProxy on the client proxy
 object? Is a new connection created? Or the root vended object's
 connection can be reused? In the latter case if I remove that
 connection from the main run loop and call -runInNewThread, would the
 root object's operation be broken?

 The server creates one NSConnection instance and registers it under a name.  
 This connection doesn't actually send data to any client.  It listens for 
 connections from clients and, when one connects, creates a new NSConnection 
 instance to conduct the communication with that client.  The new NSConnection 
 is a child of the original one.  (If you've ever worked with BSD sockets, 
 this should be familiar.  The server creates one socket file descriptor with 
 the socket() call, calls bind() and listen() on it, and then accept()s new 
 file descriptors as connections are made.)

 The -connectionForProxy method returns the existing connection being used to 
 convey messages to the proxy to its distant real object.  This will be 
 different from the NSConnection object the server originally created and 
 registered.  It will be one of the child connections.


 2. I tried to launch two client threads simultaneously and pass
 different objects to the check-in method, and I see that the
 connection returned from -connectionForProxy is the same for the both
 threads. Is it a problem? Won't the two threads somehow interfere?

 I believe you are being bitten by what I wrote about here:

 On Tue, Sep 28, 2010 at 9:12 AM, Ken Thomases k...@codeweavers.com wrote:

 For a multi-threaded client which wants to have several connections to the 
 same server, you may have to jump through a couple of hoops.  NSConnection 
 is pretty eager about reusing its instances if they match a new request.  
 You may need to create the connection somewhat manually by creating the 
 ports and then explicitly using +connectionWithReceivePort:sendPort: or 
 -initWithReceivePort:sendPort:.

 Two threads within one process may very well get the same connection to the 
 server.  The simple methods for getting the connection (or ignoring the 
 connection and just getting the root proxy) just ask by name.  NSConnection 
 will realize it already has a connection for that name and reuse it.  So, you 
 probably shouldn't use:

 +connectionWithRegisteredName:host:
 +connectionWithRegisteredName:host:usingNameServer:
 +rootProxyForConnectionWithRegisteredName:host:
 +rootProxyForConnectionWithRegisteredName:host:usingNameServer:

 Instead, you should create two ports of the appropriate type.  If you're 
 using Mach ports for communication, then you want NSMachPorts.  If you're 
 using sockets for communication, then NSSocketPorts.

 You should get the send port from the appropriate port name server.  For 
 example, [[NSMachBootstrapServer sharedInstance] portForName:@foo] or 
 [[NSSocketPortNameServer sharedInstance] portForName:@foo 
 host:@server.example.com].  This send port is still likely to be shared by 
 the threads.

 So, you should create a separate receive port for each thread.  That's the 
 part which ensures that each thread has a separate NSConnection (both on the 
 client side and the server side).  For example [NSMachPort port] or 
 [NSSocketPort port].

 Then, you should create the connection to the server from those two ports, 
 using one of:

 +connectionWithReceivePort:sendPort:
 -initWithReceivePort:sendPort:

 Read the documentation for the latter of those to learn about NSConnection 
 object re-use/sharing.  Those docs suggest you may be able to get away 
 without creating a unique receive port manually.  If you pass nil, it should 
 create one for you.  Test to make sure the connection objects your client 
 threads are getting are unique from one another.

 Then call -rootProxy on the created connection object to get the server's 
 vended object.

 Cheers,
 Ken


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to 

Tracking Area resets to view's bounds

2010-09-28 Thread Jim Thomason
I'm utterly confused by what I thought would be something simple.

I have a custom view that I want to establish a few tracking areas
for. So I go and create several NSTrackingAreas and add them to the
view. All looks well. But later on, when my mouse events fire off,
they're associated with the ENTIRE view, not just my tracking area.
Even more bizarre, the tracking area at the memory address I
originally created has had its associated rect adjusted to be the
view.

I've boiled it down to a trivial test case.

- (id)initWithFrame:(NSRect)frame {
self = [super initWithFrame:frame];
if (self) {
//this one ends up with a tracking area encompassing the entire view
[self addTrackingArea:
[[[NSTrackingArea alloc]
initWithRect:NSMakeRect(100, 100, 50, 50)
options:NSTrackingActiveInKeyWindow
 | NSTrackingMouseEnteredAndExited |
NSTrackingMouseMoved | NSTrackingInVisibleRect owner:self userInfo:nil
] autorelease]
];

//this one works as expected
[self addTrackingRect:NSMakeRect(100,100,50,50) owner:self
userData:nil assumeInside:NO];

NSLog(@HAS TRACKING AREAS %@, [self trackingAreas]);
}
return self;
}

- (void)mouseEntered:(NSEvent *)theEvent {
NSLog(@MOUSE ENTERED  IN %@, [theEvent trackingArea]);return;
}

If I do it new-style with addTrackingArea, then the entire view
becomes my tracking area. If I do it old-style with addTrackingRect,
it behaves as I would've expected. For example, doing it with tracking
areas:


2010-09-28 13:26:41.564 TrackingAreaTest[32602:a0f] HAS TRACKING AREAS (
NSTrackingArea 0x100621760: rect={{100, 100}, {50, 50}},...)
2010-09-28 13:26:43.122 TrackingAreaTest[32602:a0f] MOUSE ENTERED  IN
NSTrackingArea 0x100621760: rect={{0, 0}, {400, 400}}, ...
2010-09-28 13:26:43.539 TrackingAreaTest[32602:a0f] MOUSE EXITED FROM
NSTrackingArea 0x100621760: rect={{0, 0}, {400, 400}}, ...

Same tracking area (or same memory address, at least), but different
rectangles. Only difference I can see is that the first one (called
right after I set it) has extra flags of pendingInstall notInstalled
disabled. The one I get from mouseEntered is installed enabled.

I'm completely stumped. Surely I'm doing something horribly stupid,
but bugger all if I know what it is. What do I need to do to make it
work?

Sample code at:
http://www.prototypesite.net/trackingareatest.zip

-Jim.
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Tracking Area resets to view's bounds

2010-09-28 Thread Quincey Morris
On Sep 28, 2010, at 11:34, Jim Thomason wrote:

[self addTrackingArea:
[[[NSTrackingArea alloc]
initWithRect:NSMakeRect(100, 100, 50, 50)
 options:NSTrackingActiveInKeyWindow
 | NSTrackingMouseEnteredAndExited |
 NSTrackingMouseMoved | NSTrackingInVisibleRect owner:self userInfo:nil
] autorelease]

From the NSTrackingArea class reference, for the constant 
NSTrackingInVisibleRect:

 Mouse tracking occurs only in the visible rectangle of the view—in other 
 words, that region of the tracking rectangle that is unobscured. Otherwise, 
 the entire tracking area is active regardless of overlapping views. The 
 NSTrackingArea object is automatically synchronized with changes in the 
 view’s visible area (visibleRect) and the value returned from rect is ignored.

Note the last sentence.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: I want a window's file owner that's not a NSWindowController

2010-09-28 Thread Chris Hanson
On Sep 28, 2010, at 10:47 AM, Shawn Bakhtiar wrote:

 Question, why not just derive the camera class from NSWindow?

A camera is not a different kind of window.  The only significant reason to 
subclass NSWindow is to create a new kind of window - not a window for a 
specific task.

 There is no programmatic need for NSWindowController, as an NSWindow is also 
 an NSResponder (can take all input).

The need for NSWindowController is to manage interaction between model-level 
and view-level objects, as with all controllers.

In the original poster’s case I wouldn’t make Camera a subclass of 
NSWindowController and I *certainly* wouldn’t make Camera a subclass of 
NSWindow.  Instead, I would create a CameraSettingsPanelController subclass of 
NSWindowController, with a “camera” property to present the Camera for which it 
presents settings.

This is the route Quincey Morris suggested as well.

I suspect that the CameraSettingsPanelController class will grow over time, 
from a class that (say) just implements -init (since it’s likely to use a nib 
with a fixed name) and a “camera” property, to also implementing logic for 
saving and loading settings specific to a Camera, managing interaction between 
the Camera it presents and the views in the panel representing its settings — 
for example, by acting as an NSTableView delegate and data source for managing 
drag  drop — and so on.

It may not wind up a very “thick” class, but my guess is that in the end it 
won’t be entirely free of interesting code either.

  -- Chris

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Disabling selection of files in NSOpenPanel

2010-09-28 Thread Dave DeLong
Hi everyone,

I'm using NSOpenPanel, and I'd like the ability to disable files and folders 
under certain conditions (for example if a file is on an external drive versus 
the boot volume).  10.6 introduced a delegate method called 
panel:shouldEnableURL: which would be perfect, but I need a 
Leopard-compatible solution.

Any ideas how I could do this?

Thanks,

Dave

smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: I want a window's file owner that's not a NSWindowController

2010-09-28 Thread Jonny Taylor
 I am trying to understand the right way of dealing with a settings window 
 in my application. I have a Camera object that wraps a Firewire video 
 camera. I would like to bring up an NSPanel that enables various settings of 
 the camera to be modified. I do not need to override any particular 
 behaviours of NSWindowController, and it seems to me that logically my 
 Camera object should not need to inherit from NSWindowController (the window 
 business is a bit of a distraction from the main purpose of the camera 
 class, which is handling received frames - and in future I may want more 
 than one such camera-related window).
 ...

Shawn Bakhtiar wrote:
 NSWindowController is for when you want to have multiple windows of the same 
 class (derived from NSWindow), but have different set of callbacks, in 
 different Window controllers that you can attach to each identical NSWindow, 
 in essence giving you a window class, that can have a different set of 
 callback functions.
 
 Question, why not just derive the camera class from NSWindow? There is no 
 programmatic need for NSWindowController, as an NSWindow is also an 
 NSResponder (can take all input).
Interesting point, but I still feel this doesn't make a lot of logical sense 
because the camera is not a type of window (or indeed window controller) - 
plus, as I say, there's no reason I shouldn't have more than one different 
window associated with the camera...

Quincey Morris wrote:
 You're kind of mixing up two different tasks here. The Camera object is 
 (likely) part of your data model (in the MVC paradigm). A window controller 
 is a ... controller. For your settings window, you'll have least heartache if 
 you make the NIB's File's Owner a window controller. Window controllers are 
 *designed* to be the owners of NIB files.
 
 So, subclass NSWindowController, and add a camera property. (Your Camera 
 object can pass its 'self' pointer as a parameter to the window controller 
 subclass's init... method.)
 
 Then, to get at Camera properties, objects in the NIB can bind to File's 
 Owner.camera.whateverProperty -- instead of File's Owner.whateverProperty as 
 you have now.
Ah, that is quite a neat solution - thanks for that. I hadn't twigged that I 
could do that sort of property of a property binding. It still seems a bit of 
a faff to create a controller subclass that isn't really doing anything other 
than passing through property requests, but at least I don't have do write 
accessors for every property I want to get at in the Camera object!


Cheers
Jonny___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Disabling selection of files in NSOpenPanel

2010-09-28 Thread Kevin Wojniak
Take a look at panel:shouldShowFilename:


On Sep 28, 2010, at 1:14 PM, Dave DeLong wrote:

 Hi everyone,
 
 I'm using NSOpenPanel, and I'd like the ability to disable files and folders 
 under certain conditions (for example if a file is on an external drive 
 versus the boot volume).  10.6 introduced a delegate method called 
 panel:shouldEnableURL: which would be perfect, but I need a 
 Leopard-compatible solution.
 
 Any ideas how I could do this?
 
 Thanks,
 
 Dave___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/kainjow%40kainjow.com
 
 This email sent to kain...@kainjow.com

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


[MEET] CocoaHeads Mac Developer Meetings

2010-09-28 Thread Stephen Zyszkiewicz
Greetings,

CocoaHeads is an international Mac programmer's group. Meetings are free and 
open to the public. We specialize in Cocoa, but everything Mac programming 
related is welcome.

Canada
Toronto, Ontario - Tuesday, October 12, 2010 18:30

France
Bordeaux - Thursday, October 28, 2010 18:00

Germany
Hannover - Tuesday, October 5, 2010 19:00

Sweden
Stockholm - Monday, October 4, 2010 19:00

U.S.A.
Ann Arbor, Michigan - Thursday, October 14, 2010 19:00
Boston, Massachusetts - Thursday, October 14, 2010 19:00
Boulder, Colorado - Tuesday, October 12, 2010 19:00
Chicago, Illinois - Tuesday, October 12, 2010 19:00
Colorado Springs, Colorado - Thursday, October 14, 2010 19:00
Dallas, Texas - Thursday, October 14, 2010 19:00
Denver, Colorado - Tuesday, October 12, 2010 19:00
Des Moines, Iowa - Thursday, October 14, 2010 19:00
Detroit, Michigan - Thursday, October 28, 2010 19:00
Lake Forest, California - Wednesday, October 13, 2010 19:00
New York, New York - Wednesday, October 13, 2010 18:00
Pittsburgh, Pennsylvania - Thursday, October 14, 2010 19:30

Some chapters may have yet to post their meeting for next month. Meeting times 
may change. Locations and more information here:
http://cocoaheads.org

Also be sure to check for an NSCoder Night in your area:
http://nscodernight.com/


Steve
Silicon Valley CocoaHeads___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Declaring a property named private and ObjC++

2010-09-28 Thread Nick Zitzmann
Okay, I tried searching, and didn't find anything pertinent...

How do I create a property for a class named private and not have the 
Objective-C++ compiler trip on it?

Here's what I first tried:

@property(assign,getter=isPrivate) BOOL private;

That @property declaration works just fine when compiling Objective-C code, but 
when the header is imported into Objective-C++ code, I get the following error 
twice:
error: expected unqualified-id before 'private'

I know the word private is used as a keyword in C++ to mark the private 
section of a class. So I tried rephrasing that property declaration to try and 
get the compiler to treat the word private as a property name and not as a 
C++ keyword. I thought this might work:

#ifdef __cplusplus
extern C {
#endif
@property(assign,getter=isPrivate) BOOL private;
#ifdef __cplusplus
}
#endif

But I still get a compiler error:
error: misplaced '@property' Objective-C++ construct

I'm using GCC 4.2 as the compiler. At this point it's not a big deal, because I 
can still use old-school property declarations, but it would be nice to know 
how to fix this problem (if possible)...

Nick Zitzmann
http://www.chronosnet.com/

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Declaring a property named private and ObjC++

2010-09-28 Thread Ricky Sharp

On Sep 28, 2010, at 6:19 PM, Nick Zitzmann wrote:

 Okay, I tried searching, and didn't find anything pertinent...
 
 How do I create a property for a class named private and not have the 
 Objective-C++ compiler trip on it?
 
 Here's what I first tried:
 
 @property(assign,getter=isPrivate) BOOL private;
 
 That @property declaration works just fine when compiling Objective-C code, 
 but when the header is imported into Objective-C++ code, I get the following 
 error twice:
 error: expected unqualified-id before 'private'
 
 I know the word private is used as a keyword in C++ to mark the private 
 section of a class. So I tried rephrasing that property declaration to try 
 and get the compiler to treat the word private as a property name and not 
 as a C++ keyword. I thought this might work:


Why do you need to use the exact name of private?  You should never name 
things using reserved words.

How about simply adding a suffix or prefix?

___
Ricky A. Sharp mailto:rsh...@instantinteractive.com
Instant Interactive(tm)   http://www.instantinteractive.com



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Declaring a property named private and ObjC++

2010-09-28 Thread Nick Zitzmann

On Sep 28, 2010, at 5:51 PM, Ricky Sharp wrote:

 Why do you need to use the exact name of private?  

Because the object in question has a private state.

 You should never name things using reserved words.

But it's not a reserved word in Objective-C. @private is, private is not.

Nick Zitzmann
http://www.chronosnet.com/

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Declaring a property named private and ObjC++

2010-09-28 Thread Greg Parker
On Sep 28, 2010, at 4:19 PM, Nick Zitzmann wrote:
 Okay, I tried searching, and didn't find anything pertinent...
 
 How do I create a property for a class named private and not have the 
 Objective-C++ compiler trip on it?

You can't. C++ reserved words are unavailable for use in Objective-C++. The 
only exception is in method names.


-- 
Greg Parker gpar...@apple.com Runtime Wrangler


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Declaring a property named private and ObjC++

2010-09-28 Thread Nick Zitzmann

On Sep 28, 2010, at 6:07 PM, Greg Parker wrote:

 How do I create a property for a class named private and not have the 
 Objective-C++ compiler trip on it?
 
 You can't. C++ reserved words are unavailable for use in Objective-C++. The 
 only exception is in method names.

Okay, thank you for clarifying that.

Nick Zitzmann
http://www.chronosnet.com/

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Declaring a property named private and ObjC++

2010-09-28 Thread Dave Carrigan
On Sep 28, 2010, at 4:57 PM, Nick Zitzmann wrote:
 
 On Sep 28, 2010, at 5:51 PM, Ricky Sharp wrote:
 
 Why do you need to use the exact name of private?  
 
 Because the object in question has a private state.
 
 You should never name things using reserved words.
 
 But it's not a reserved word in Objective-C. @private is, private is not.


Objective-C != Objective-C++

And it is a reserved word in Objective-C++.

In addition, even if it were just Objective-C, it is still not generally good 
practice to use C++ reserved words (class, private, etc.). 

-- 
Dave Carrigan
d...@rudedog.org
Seattle, WA, USA

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Declaring a property named private and ObjC++

2010-09-28 Thread Rob Ross

On Sep 28, 2010, at 4:19 PM, Nick Zitzmann wrote:

 @property(assign,getter=isPrivate) BOOL private;

What about trying

@property(assign) BOOL isPrivate;

?

Rob
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Declaring a property named private and ObjC++

2010-09-28 Thread Nick Zitzmann

On Sep 28, 2010, at 6:10 PM, Dave Carrigan wrote:

 Objective-C != Objective-C++
 
 And it is a reserved word in Objective-C++.

I know; I was just wondering if there was a workaround that would tell the 
ObjC++ compiler to treat the property as if it was in ObjC (where it is not a 
reserved word) and not ObjC++. But it's already been confirmed that there 
isn't, so now we know.

Nick Zitzmann
http://www.chronosnet.com/

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Acquiring an NSConnection otherwise than by registered name?

2010-09-28 Thread Ken Thomases
On Sep 28, 2010, at 1:23 PM, Oleg Krupnov wrote:

 So, let's assume I create the connection in this way:
 
 NSConnection* connection = [NSConnection connectionWithReceivePort:nil
 sendPort:[[NSMachBootstrapServer sharedInstance] portForName:@foo]];
 
 or even
 
 NSConnection* connection = [NSConnection
 connectionWithReceivePort:[NSMachPort port] sendPort:[NSMachPort
 port]];
 
 Then I vend the object:
 
 [connection setRootObject:serverObject];
 
 And finally launch it in a separate thread:
 
 [connection runInNewThread];
 
 But how do I pass this connection back to client so that I could call
 -rootProxy on it?

You don't.  Please reread what I wrote.  My last email was largely about how 
the client creates its connection.  You've misunderstood it to be about how the 
server creates it.  (The above approaches wouldn't even work for a server.)

Servers don't create connections to clients.  Clients create connections to 
servers.

A server only explicitly creates a single NSConnection instance.  This isn't a 
connection so much as a connection point -- a place where clients can connect 
to.

Then, clients create connections to the server.  In response, in the server, 
the frameworks implicitly create new NSConnection instances for each client 
connection.  Once again, this is clearly illustrated in the documentation on 
Distributed Objects.  Have you read it?
http://developer.apple.com/library/mac/#documentation/cocoa/Conceptual/DistrObjects/Concepts/connections.html

We've already discussed how and when the server tells the newly-created 
connections to run in a separate thread.

The only complication is that, because your clients are attempting to make 
multiple connections from the same process, and because the frameworks try to 
reuse connections within a process, you have to take some minor extra 
precautions to make sure you are getting separate, independent connections to 
the server.  I have told you how to do that.

 That was actually the original question in the
 subject of this mail :)

Not as I understood it.  And if it was, then you have a fundamental 
misunderstanding about how connections work.  Again: servers don't create 
connections to clients; clients create connections to servers.

 The other question I've got is how do I exit the newly created thread
 when its job is done?

It should exit when the connection from the client closes.  It's possible that 
the server will have to explicitly -invalidate the connection in response to a 
sign-off message from the client.

Regards,
Ken

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


iPad Custom Font Issue

2010-09-28 Thread Brian Slick
A client has provided 4 fonts they would like me to use in their iPad app.  
These fonts are all from the same family, just with different line weights.  
(light, normal, bold, etc).  They are *.otf files.  I have added them to the 
project, and listed them in info.plist.

I put together a quick test app intended to show each font in a row of a table 
view.  But instead of seeing 4 distinct fonts, I see 2.  The first item 
displays correctly, and then the remaining 3 all display with the same font.  
So, say the first is bold, the others are all light.  The font _is_ being 
applied, as I'm not seeing the system font, but the line weight is not correct.

I have added the fonts to Font Book on my Mac, displayed them in Mail, etc. and 
they are indeed distinct.  Four different line weights.

If I ask for fontNamesForFamilyName: I get back an array containing four items, 
and the names appear correct.  However, I only observe two different fonts both 
in the simulator and on the device.

I shared these fonts with another developer who confirmed my observations.  He 
also conducted more extensive testing and discovered that the UIFont object 
getting created (fontWithName:size:) is the same instance for the 3 items that 
display the same.  I suppose that would explain why they look the same.

In response to a forum post on this matter, someone else told me that through 
extensive testing, he had determined that only 2 styles per family are 
supported.  UIFont documentation does not mention this, but it is consistent 
with what I'm seeing.

Bottom line, I need all four fonts.  Any suggestions on what I can do?

Thanks,

Brian
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


NSMutableDictionary crash on PPC

2010-09-28 Thread Trygve Inda

I am getting a crash after calling synchronize. I am trying to change the
key associated with an object as follows:

myDict = [myObject objectForKey:myOldKey];
if (myDict)
{
[myObject removeObjectForKey:myDict];
[myObject setValue:myDict forKey:myNewKey];

[[NSUserDefaults standardUserDefaults] synchronize];
}

It works on Intel, but crashes on PPC. Any idea why?

Trygve


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com