-2
我想發送我的字節數據使用一些存在的Web服務。現在我不想更多地探索Web服務,但我只希望將我的以下Byte數據發佈到一些已經存在的Web服務中。例如,以下是我的字節數據。發送字節數據到web服務在cocos2d iphone
Byte *byteData = (Byte*)malloc(len);
memcpy(byteData, (Byte*)myData, len);
我該怎麼做!我只想使用Existed Web Service,您的幫助將不勝感激。
EDITED
我有我的NSData JSON格式了。如下面的代碼
const unsigned char *bytes = [myData bytes]; // no need to copy the data
NSUInteger length = [myData length];
NSMutableArray *byteArray = [NSMutableArray array];
for (NSUInteger i = 0; i < length; i++)
{
[byteArray addObject:[NSNumber numberWithUnsignedChar:bytes[i]]];
}
NSDictionary *dictJson = [NSDictionary dictionaryWithObjectsAndKeys:
byteArray, @"vedio",
nil];
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dictJson options:0 error:NULL];
你的web服務有什麼參數? – Robert
Web服務究竟是如何接收數據的?什麼格式(JSON,XML,URL參數...)它預期的是什麼? – LearnCocos2D
@ LearnCocos2D我對這部分稱爲Web服務非常陌生,不知何故,我需要以字節格式將我的數據發送到我的Web服務,我將使用Json&post方法,如鏈接http://www.raywenderlich .com/2965/how-to-write-an-ios-app-that-uses-a-web-service ...仍然我很困惑我該如何做到這一點.. –