从小数据转换大量nsdata?

时间:2014-09-30 10:05:19

标签: ios iphone

我的NSData对象大约有50MB。现在我想通过udpSocket.but 2kb向上传输数据不发送....如何将此nsdata小文件或数据转换为大约2kb。

我使用此代码发送nsdata:

- (IBAction)send:(id)sender
{
NSString *host = addrField.text;

if ([host length] == 0)
{
    [self logError:@"Address required"];
    return;
}

int port = [portField.text intValue];
if (port <= 0 || port > 65535)
{
    [self logError:@"Valid port required"];
    return;
}

NSString *msg = [[NSBundle mainBundle] pathForResource:@"veer" ofType:@"mp3"];
if ([msg length] == 0)
{
    [self logError:@"Message required"];
    return;
}

NSData* data =[[NSData alloc]init];
data= [NSData dataWithContentsOfFile:msg];



[udpSocket sendData:data toHost:host port:port withTimeout:-1 tag:tag];
NSLog(@"%ld",tag);

[self logMessage:FORMAT(@"SENT (%i): %@", (int)tag, msg)];
udpSocket = [[GCDAsyncUdpSocket alloc] initWithDelegate:self  delegateQueue:dispatch_get_main_queue()];

//omitted error checking
[udpSocket bindToPort:port error:nil];
[udpSocket joinMulticastGroup:host error:nil];
[udpSocket beginReceiving:nil];


tag++;
 }

只发送2200字节大小而不是nsdata.2200字节向上(大)数据不发送请给出任何解决方案。

0 个答案:

没有答案