FROM : Adam Maxwell
DATE : Thu Jul 20 21:02:38 2006
On Thursday, July 20, 2006, at 10:26AM, Bryan Bonczek <<email_removed>> wrote:
>
>Hello all,
>
>I have been experiencing some difficulties using NSConnection (using socket ports) to send a message to a vended object that takes a custom object as a parameter.
>
>For example, if I have the following method in my vended object:
>
>-(void)receiveMessage:(MyCustomObject*)myObject
>
>and then I try to send a message to it, I get an NSInternalConsistencyError saying that the object cannot be unpacked.
>
>However, if I change the method to:
>
>-(void)receiveMessage:(NSString*)stringObject
>
>and send an NSString, the NSString gets unpacked just fine.
>
>
>Has anyone else encountered this problem? Why does this work for Foundation objects and not my custom object? Is there a protocol that MyCustomObject needs to implement in order for this to work?
It sounds like you need to implement NSCoding. You may also want to implement replacementObjectForPortCoder: (see the docs for a sample implementation) if you want your object passed by copy. It's also worth noting that NSPortCoder doesn't support keyed archiving.
hth,
Adam
DATE : Thu Jul 20 21:02:38 2006
On Thursday, July 20, 2006, at 10:26AM, Bryan Bonczek <<email_removed>> wrote:
>
>Hello all,
>
>I have been experiencing some difficulties using NSConnection (using socket ports) to send a message to a vended object that takes a custom object as a parameter.
>
>For example, if I have the following method in my vended object:
>
>-(void)receiveMessage:(MyCustomObject*)myObject
>
>and then I try to send a message to it, I get an NSInternalConsistencyError saying that the object cannot be unpacked.
>
>However, if I change the method to:
>
>-(void)receiveMessage:(NSString*)stringObject
>
>and send an NSString, the NSString gets unpacked just fine.
>
>
>Has anyone else encountered this problem? Why does this work for Foundation objects and not my custom object? Is there a protocol that MyCustomObject needs to implement in order for this to work?
It sounds like you need to implement NSCoding. You may also want to implement replacementObjectForPortCoder: (see the docs for a sample implementation) if you want your object passed by copy. It's also worth noting that NSPortCoder doesn't support keyed archiving.
hth,
Adam
| Related mails | Author | Date |
|---|---|---|
| Bryan Bonczek | Jul 20, 19:24 | |
| mirage07 | Jul 20, 19:43 | |
| Adam Maxwell | Jul 20, 21:02 |






Cocoa mail archive

