Java 通过分配NSOutputStream值。NSURL连接
我有这样一个Java代码Java 通过分配NSOutputStream值。NSURL连接,java,objective-c,Java,Objective C,我有这样一个Java代码 OutputStream os = null; URLConnection conn = null; conn = getConnection(url, fileSize,index, size,fileId, fileName); //this method's return type is URLConnection os = conn.getOutputStream(); os.write(buf); //buff is a byte array os.flus
OutputStream os = null;
URLConnection conn = null;
conn = getConnection(url, fileSize,index, size,fileId, fileName); //this method's return type is URLConnection
os = conn.getOutputStream();
os.write(buf); //buff is a byte array
os.flush();
我正在用Objective-C编写这段代码,在将NSURLConnection对象分配给NSOutputStream时遇到了一个问题。有人能帮我做到这一点吗 参见苹果的文档。这项技术并不简单,但文档很全面。您好,谢谢您的回答。我之前遵循此文档进行了初始连接,工作正常。我在这里遇到的唯一问题是使用NSURLConnection对象的指定值生成输出流,并将我已经读取的字节作为主体附加到buf中。也许我不理解这个问题,但指南说明了如何执行此操作。NSURLConnection没有输出流;相反,它接受一个委托,它在每次接收数据时调用该委托(特别请参见connection:didReceiveData:message)。在委托内部,您可以将数据附加到NSMutableData对象(或您想要的任何其他对象),直到下载完成。具体参见清单3和5。