Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 01-03-2010, 01:36 PM   #1 (permalink)
Registered Member
 
Join Date: May 2009
Posts: 28
Default Game Kit Bluetooth sending NSData

Hi

I am trying to develop a multiplayer game which uses the gameKit framework in OS 3.0. However I have come across some problems. Mainly sending data between devices.

I can connect two devices using the picker - that is fairly easy, however I am unsure about the whole NSData object thing I am supposed to be sending between the devices.

I want to send several vars such as NSInteger, NSString, CGPoint and CGFloats. I thought a good way to do this would be to tie these up in an array and send that, but how do I turn that into NSData and then reassemble that at the other end?

Or is there a better way?

Any light you can shed on the matter would be greatly appreciated.

Thanks

Jetwilson
__________________
Jetwilson

visit my twitter site for all news about my projects and apps in development.

Advanced ROX is now available on iTunes Worldwide!
http://itunes.com/apps/jetwilson/advancedrox
jetwilson is offline   Reply With Quote
Old 01-03-2010, 03:40 PM   #2 (permalink)
Registered Member
 
Join Date: Sep 2008
Posts: 109
Default

Here's how I send data:

Code:
NSMutableData *message = [[NSMutableData alloc] init];
				NSKeyedArchiver *archiver =
				[[NSKeyedArchiver alloc] initForWritingWithMutableData:message];
				[archiver encodeInt:myInt forKey:DISMISS_KEY];
				[archiver finishEncoding];
				[gkSession sendDataToAllPeers: message withDataMode:GKSendDataReliable error:NULL];
				[archiver release];
				[message release];
davidlansalot is offline   Reply With Quote
Reply

Bookmarks

Tags
bluetooth, game kit, nsdata

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 356
22 members and 334 guests
ADY, Dani77, Duncan C, e2applets, Grinarn, HemiMG, Herbie, JasonR, keeshux, linkmx, macquitzon216, mer10, Monstertaco, prchn4christ, Promo Dispenser, Robiwan, sebasx, sly24, Touchmint, twerner, zulfishah
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,881
Threads: 89,228
Posts: 380,760
Top Poster: BrianSlick (7,129)
Welcome to our newest member, macquitzon216
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 01:37 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0