nsinputstream

iOS how can i perform multiple NSInputStream

你说的曾经没有我的故事 提交于 2021-02-08 08:05:57
问题 My app uses NSInputStream like below: inputStream.delegate = self; [inputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; [readStream open]; and delegate: - (void)stream:(NSStream *)theStream handleEvent:(NSStreamEvent)streamEvent It works fine, but all other requests that i do, it queued until first is finished. I can do one per time and there is no way to do multiple concurrent requests. There is a solution ? Thank you This solution not work for me : https:

NSURLSession with upload stream - subclassing NSInputStream - com.apple.NSURLConnectionLoader exception

空扰寡人 提交于 2020-01-14 03:01:09
问题 Basic task I have some multiplatform library which is using some C++ stream interface. I have to use this stream interface to upload data by NSURLSession . My implementation should work on OS X and iOS (currently I'm testing on OS X) What I did Task looks quite simple and I was sure I will implement this quite fast. I have configured NSURLSession which is working fine if I'm using NSURLRequest with simple NSData . I'm trying to use stream like this: NSURLSessionDataTask *dataTask = [m_Private

iOS - Setting delegate of input stream to another class

陌路散爱 提交于 2020-01-03 03:06:07
问题 i am wondering that if it is possible to set the delegate of input stream to another class. So far all examples i have encountered are with self: [inputStream setDelegate:self] . I want to set delegate to another class like a ViewController not self. Thanks in advance. 回答1: if your ViewController is responding to NSStreamDelegate , you can initiate an instance of the controller and set the delegate as usual. @interface ViewController : NSOperation<NSStreamDelegate> ... - ViewController *vc =

-[NSInputStream read:maxLength:] throws an exception saying length is too big, but it isn't

限于喜欢 提交于 2019-12-30 09:44:10
问题 I use an NSInputStream to read data from a file. It will crash if maxLength is greater than 49152. When it crashes -- sometimes, but not every time, it gives this message: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSConcreteData initWithBytes:length:copy:freeWhenDone:bytesAreVM:]: absurd length: 4294967295, maximum size: 2147483648 bytes' From my calculation, 524288 is still less than that maximum, and can fit in the return value. What did I

Memory issue while converting big video file path to NSData. How to use InputStream/FileHandle to fix this issue?

佐手、 提交于 2019-12-25 01:34:11
问题 I have a large sized video saved in my documents directory. I want to retrieve this video and remove it's first 5 bytes. For large video files of above 300 MB using [NSData(contentsOf: videoURL)] causing Memory issue error. I have gone through Swift: Loading a large video file (over 700MB) into memory and found that we need to use [InputStream] and [OutputStream] or [NSFileHandle]for large files. How to use it? Sample code is given below: let nsDocumentDirectory = FileManager

iOS input stream receives fast data only if output stream is simultaneously sending

独自空忆成欢 提交于 2019-12-24 10:46:15
问题 My iOS app requires socket communication. I'm following this Ray Wenderlich tutorial for setting up the input and output streams. The server I'm using is Twisted. My app requires sending and receiving fast bursts of data generated by external events like gyroscope data. It is sending/receiving data in form of JSON string. So largely, it's very much like a real-time messaging chat app but sending and receiving is very fast and in bursts. So my app layout is that I have 1 view controller:

I cannot initialize a NSInputStream

 ̄綄美尐妖づ 提交于 2019-12-23 01:21:13
问题 Please help me, im going insane. I need to create an NSInputStream so i can read a live preview from a camera over wifi. liveViewStream is an NSInputStream -Instance-Variable that is declared in my implementation like so: @implementation MKSonyCamHandler{ NSInputStream *liveViewStream; } liveViewURL is a valid URL that i can open in my browser when i connect to the camera's network (although i dont think that this makes any difference). I have checked that it exists, is not nil and holds the

How to convert NSInputStream to NSString or how to read NSInputStream

不羁岁月 提交于 2019-12-22 14:42:00
问题 I'm trying to convert my input stream to a string. The input stream I'm trying to convert is NSURLRequest.HTTPBodyStream, apparently the httpbody is set to null and replaced with the stream after you make the request. how do I go about doing this? This is what I have so far: #define MAX_UTF8_BYTES 6 NSString *utf8String; NSMutableData *_data = [[NSMutableData alloc] init]; //for easy 'appending' bytes int bytes_read = 0; while (!utf8String) { if (bytes_read > MAX_UTF8_BYTES) { NSLog(@"Can't

Convert an Objective-C method into Swift for NSInputStream (convert bytes into double)

自闭症网瘾萝莉.ら 提交于 2019-12-19 10:08:28
问题 I have the following code in Objective-C: - (double)readDouble { double value = 0.0; if ([self read:(uint8_t *)&value maxLength:8] != 8) { NSLog(@"***** Couldn't read double"); } return value; } It works. But I don't know how to convert it to Swift. Here is my code: public func readDouble() -> Double { var value : Double = 0.0 var num = self.read((uint8_t *)&value, maxLength:8) // got compiling error here! if num != 8 { } } The error message is: Cannot invoke '&' with an argument list of type

NSInputStream getBuffer: length: doesn't work?

青春壹個敷衍的年華 提交于 2019-12-14 01:23:15
问题 I really would like to use the getBuffer:length: method of an NSInputStream. After a lot of research i couldn't find a valid example that uses this method, because most people really needed read: maxLength: . So now some facts on the surroundings: * I'm developing an app for the iPhone, iOS 3.1.3 * I've established a network communication via sockets * That network connection actually works; so i didn't forget to add a a stream to the runloop or a valid delegate or such things - it already