• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Can MCPeerID be used as a key in a dictionary?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Can MCPeerID be used as a key in a dictionary?


  • Subject: Re: Can MCPeerID be used as a key in a dictionary?
  • From: "Quinn \"The Eskimo!\"" <email@hidden>
  • Date: Fri, 23 May 2014 09:54:46 +0100

On 23 May 2014, at 02:33, Rick Mann <email@hidden> wrote:

> Is MCPeerID usable as a key?

Yes.

> It can be used as a key, I've verified that, but will I only ever get the same instance for a specific peer, even after disconnecting and re-connecting?

This speaks to a fundamental question about identity.  The answer often depends on the specifics of your app, but I can explain the mechanics at which point you can implement whatever policy you need.

Specifically, an MCPeerID is fundamentally a wrapper around a big random number.  This number is generated each time you alloc/init a new MCPeerID.  It's not related to the display name.

Thus, if you want to look like a new peer, you should alloc/init a new MCPeerID. OTOH, if you want to look like the same peer as before, you should reuse your only MCPeerID.

MCPeerID is archivable, which is the recommended way to appear as the same peer across launches of your app.

> Should each peer generate a UUID that remains constant for the life of the app on that device, and send that over during connection?

Lots of folks do that, but only because they don't understand that MCPeerID is already doing it for them )-:  I've filed a bug <rdar://problem/16837396> to improve the docs on this front.

Share and Enjoy
--
Quinn "The Eskimo!"                    <http://www.apple.com/developer/>
Apple Developer Relations, Developer Technical Support, Core OS/Hardware



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

This email sent to email@hidden


  • Follow-Ups:
    • Re: Can MCPeerID be used as a key in a dictionary?
      • From: Rick Mann <email@hidden>
    • Re: Can MCPeerID be used as a key in a dictionary?
      • From: Rick Mann <email@hidden>
References: 
 >Can MCPeerID be used as a key in a dictionary? (From: Rick Mann <email@hidden>)

  • Prev by Date: Can MCPeerID be used as a key in a dictionary?
  • Next by Date: Re: Can MCPeerID be used as a key in a dictionary?
  • Previous by thread: Can MCPeerID be used as a key in a dictionary?
  • Next by thread: Re: Can MCPeerID be used as a key in a dictionary?
  • Index(es):
    • Date
    • Thread