nsoutputstream

Using NSOutputStream to POST to url

泄露秘密 提交于 2019-12-03 21:16:00
So all I want to do is send a POST request to a url. Now I tried using NSURLRequest/NSURLConnection, but was having problems with that and decided to move to a lower level, also because I want to send large files and thought dealing directly with streams might be better. But the output stream delegate never seems to be called, and I can't seem to find examples using NSOutputStream's initWithURL . NSURL *url = [NSURL URLWithString:NSString stringWithFormat: @"http://url"]; self.outputStream = [[NSOutputStream alloc] initWithURL:url append:NO]; [outputStream retain]; [outputStream setDelegate

Cocoa NSOutputStream send to a connection

家住魔仙堡 提交于 2019-12-02 07:20:16
问题 I am new to Cocoa, but managed to get a connection (to a FTP) up and running, and I've set up an eventhandler for the NSInputStream iStream to alert every response (which also works). What I manage to get is simply the hello message and a connection timeout 60 sec, closing control connection. EDIT: I guess my question is "without closing->opening what would be an non-terminating way of flushing the outputStream? After searching stackoverflow and finding a lot of NSOutputStream write problems

Do the stream classes in Cocoa support seeking?

北慕城南 提交于 2019-12-02 04:03:20
问题 I need a Cocoa class that can read and write from a memory stream and that supports seeking. In C#, MemoryStream supports the method seek , and in Java, ByteArrayInputStream supports the methods mark , skip , and reset . In iOS development, what are the equivalent class and method? I need the above functionality for my project, and if it is by default not supported by the iOS frameworks, what would be the best way of going about implementing my own? E.g. write my own stream subclass

Cocoa NSOutputStream send to a connection

你。 提交于 2019-12-02 03:49:27
I am new to Cocoa, but managed to get a connection (to a FTP) up and running, and I've set up an eventhandler for the NSInputStream iStream to alert every response (which also works). What I manage to get is simply the hello message and a connection timeout 60 sec, closing control connection. EDIT: I guess my question is "without closing->opening what would be an non-terminating way of flushing the outputStream? After searching stackoverflow and finding a lot of NSOutputStream write problems (e.g. How to use NSOutputStream's write message? ) and a lot of confusion in my google hits, I figured

Do the stream classes in Cocoa support seeking?

雨燕双飞 提交于 2019-12-02 02:31:40
I need a Cocoa class that can read and write from a memory stream and that supports seeking. In C#, MemoryStream supports the method seek , and in Java, ByteArrayInputStream supports the methods mark , skip , and reset . In iOS development, what are the equivalent class and method? I need the above functionality for my project, and if it is by default not supported by the iOS frameworks, what would be the best way of going about implementing my own? E.g. write my own stream subclass inheriting from NSInputStream / NSOutputStream which will internally contain custom code? An arbitrary

Writing Data to an NSOutputStream in Swift 3

为君一笑 提交于 2019-11-30 03:57:16
The solution of this question no longer works with Swift 3. There is no longer a property bytes of Data (formerly NSData . let data = dataToWrite.first! self.outputStream.write(&data, maxLength: data.count) With this code, I get the error: Cannot convert value of type 'Data' to expected argument type 'UInt8' How can you write Data to an NSOutputStream in Swift 3? NSData had a bytes property to access the bytes. The new Data value type in Swift 3 has a withUnsafeBytes() method instead, which calls a closure with a pointer to the bytes. So this is how you write Data to an NSOutputStream (without

Writing Data to an NSOutputStream in Swift 3

本小妞迷上赌 提交于 2019-11-27 13:14:25
问题 The solution of this question no longer works with Swift 3. There is no longer a property bytes of Data (formerly NSData . let data = dataToWrite.first! self.outputStream.write(&data, maxLength: data.count) With this code, I get the error: Cannot convert value of type 'Data' to expected argument type 'UInt8' How can you write Data to an NSOutputStream in Swift 3? 回答1: NSData had a bytes property to access the bytes. The new Data value type in Swift 3 has a withUnsafeBytes() method instead,