Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial

Simen Anthonsen
1,097 PointsSend multiple data
I am working on a turn based Game Center game and want to convert a string and an Int to NSData and send it to the other player.
This is how i convert the string:
let sendString = "Hello"
let data = sendString.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: true)
This is how i convert the int:
let sendInt = 2
let data = NSData(bytes: [sendInt], length: sizeof(Int))
This work, but how do i send both instances? I only manage to send one of them.
jcorum
71,828 Pointsjcorum
71,828 PointsNot sure the context you are working in, but if it's a func or a struct and you want to return two things the easiest way is usually to return a tuple.