Ios 从小数据转换大量nsdata?

Ios 从小数据转换大量nsdata?,ios,iphone,Ios,Iphone,我有一个大约50MB大的NSData对象。现在我想通过udpSocket传输此数据。但2kb以上的数据不发送…如何转换此nsdata小文件或约2kb的数据 我正在使用此代码发送nsdata: - (IBAction)send:(id)sender { NSString *host = addrField.text; if ([host length] == 0) { [self logError:@"Address required"]; return; } int port

我有一个大约50MB大的NSData对象。现在我想通过udpSocket传输此数据。但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++;
 }
-(iAction)发送:(id)发送方
{
NSString*host=addrField.text;
如果([主机长度]==0)
{
[自日志错误:@“需要地址”];
返回;
}
int port=[portField.text intValue];
如果(端口65535)
{
[自日志错误:@“需要有效端口”];
返回;
}
NSString*msg=[[NSBundle mainBundle]pathForResource:@“veer”类型:@“mp3”];
如果([msg长度]==0)
{
[自日志错误:@“需要消息”];
返回;
}
NSData*data=[[NSData alloc]init];
data=[NSData dataWithContentsOfFile:msg];
[udpSocket sendData:data to host:host port:port with timeout:-1标记:标记];
NSLog(@“%ld”,标签);
[自我日志消息:格式(@“已发送(%i):%@”,(int)标记,消息];
udpSocket=[[GCDAsyncUdpSocket alloc]initWithDelegate:self delegateQueue:dispatch_get_main_queue()];
//省略错误检查
[udpSocket bindToPort:端口错误:nil];
[udpSocket joinMulticastGroup:主机错误:nil];
[udpSocket开始接收:无];
tag++;
}

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

子数据范围:
?5961728 byet up nsdata您是否查看了
子数据范围:
的文档?它可能是你正在寻找的。另外,行
[[NSData alloc]init]无效。我分配nsdata查看代码似乎应该调用
udpSocket:didNotSendDataWithTag:dueToError:
。另外,为什么不使用
subdataWithRange:
将大数据切割成小数据呢?由于系统原因,最大尺寸显然无法超过: