Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: Remote Messaging
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Remote Messaging



Gordon,

On Oct 2, 2010, at 11:51 PM, Gordon Apple wrote:

> I assume that object ids get assigned at run time.

An object "id" is just its plain memory address. When an object is created and its memory get allocated, it gets "id".

(A few objects might get addresses/ids alloc'd link time -- e.g., string constants -- but that's just a side note.)

> What about selectors?

They are (at this moment, it might change in future, though such a change is very improbable) also addresses -- addresses of message-descripting structures in ObjC runtime tables.

These tables are created compile-time, and the concrete addresses get fixed link-time.

For your purpose though selectors are of no use, for their values are process-specific: you can depend on a message to always get the same selector inside a process, but the very same message might get a different selector in another process.

Use plain message names (see NSStringFromSelector).

> I'm looking at doing remote control, say between two iPads or between an
> iPhone and an iPad, or either one to a Mac application.

If you happen to be focused on iOS-iOS and Mac is not that important, read on GameKit. It is a very improperly named general bluetooth-based communication library, nothing game-specific there; and it is quite easy to use.

Alas, betwixt iOS and Mac OS X you must go TCP (since far as I know -- someone please correct me if I am wrong -- there's no GameKit for Mac OS X and hardly there will ever be, for the protocol is undocumented; and there is no way to control bluetooth low-level on iOS).

> I was wondering if there is a way to simply send normal code messages
> instead, using a uniform message translator.

There is a much better way, check Distributed Objects (NSConnection etc.) Alas, for reasons unknown, unsupported on iOS, so it's not a big help for you; nevertheless, it's a good example of what you can rig for yourself.

> Would this require exposing a
> table of selectors and ids which the remote control unit would read when
> first connecting?  Is this practical?  Is there anything obvious I'm missing
> here?

Actually for a RC I would guess a hi-level control protocol based on text commands which not necessarily are represented by ObjC messages on either side might be a better solution.

Nevertheless, if you want to do that, it's not that difficult. You need to transfer class names, message names, and object addresses (ids); the last need to be translated to local proxy objects (see NSProxy) and uniqued. See the aforementioned DO's for details of a concrete (and very good) implementation; you can play with them on Mac OS X to see how it works.

Best,
---
Ondra Čada
OCSoftware:     email@hidden               http://www.ocs.cz
private         email@hidden             http://www.ocs.cz/oc



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Objc-language mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Remote Messaging (From: Gordon Apple <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.