cfreadstream

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 =

Keep alive UDP socket in background for ios

耗尽温柔 提交于 2019-12-11 02:56:46
问题 My question is not actually what is the code to keep UDP socket alive when application in background but a confusion about the documentation in apple developer site. According to apple developer guide if i set kCFStreamNetworkServiceType to kCFStreamNetworkServiceTypeVoIP then this socket will be managed specially by system when app in background. In CocoaAsyncSocket library they reported that this settings is not working in UDP socket but only in TCP socket. I also tested this option for

Get file size on FTP download

六眼飞鱼酱① 提交于 2019-12-02 12:47:15
问题 im testing around with the "SimpleFTPSample" project from apple to understand how ftp with iOS works. i have added two lines in the "GetController.m" to get the size of the file to download. -(void)_startReceive { . . . // Open a CFFTPStream for the URL. ftpStream = CFReadStreamCreateWithFTPURL(NULL, (CFURLRef) url); CFReadStreamSetProperty(ftpStream, kCFStreamPropertyFTPFetchResourceInfo, kCFBooleanTrue); // Added: To get file size . . . } - (void)stream:(NSStream *)aStream handleEvent:

Get file size on FTP download

拥有回忆 提交于 2019-12-02 02:48:19
im testing around with the " SimpleFTPSample " project from apple to understand how ftp with iOS works. i have added two lines in the "GetController.m" to get the size of the file to download. -(void)_startReceive { . . . // Open a CFFTPStream for the URL. ftpStream = CFReadStreamCreateWithFTPURL(NULL, (CFURLRef) url); CFReadStreamSetProperty(ftpStream, kCFStreamPropertyFTPFetchResourceInfo, kCFBooleanTrue); // Added: To get file size . . . } - (void)stream:(NSStream *)aStream handleEvent:(NSStreamEvent)eventCode { . . . switch (eventCode) { case NSStreamEventOpenCompleted: { // Added: Finally

iOS Voip Socket will not run in background

对着背影说爱祢 提交于 2019-11-26 23:50:40
I am getting a VOIP socket to run in the background in an iOS application. My connection works fine, but it won't wake up when my app goes into the background. If I open the app back up, though, it responds to any messages it got while it was asleep. I set up my stream like this: CFStreamCreatePairWithSocketToHost(kCFAllocatorDefault, (CFStringRef) @"test.iusealocaltestserver.com", 5060, &myReadStream, &myWriteStream); CFReadStreamSetProperty ( myReadStream, kCFStreamNetworkServiceType, kCFStreamNetworkServiceTypeVoIP ); CFSocketNativeHandle native; CFDataRef nativeProp =

iOS Voip Socket will not run in background

非 Y 不嫁゛ 提交于 2019-11-26 08:48:02
问题 I am getting a VOIP socket to run in the background in an iOS application. My connection works fine, but it won\'t wake up when my app goes into the background. If I open the app back up, though, it responds to any messages it got while it was asleep. I set up my stream like this: CFStreamCreatePairWithSocketToHost(kCFAllocatorDefault, (CFStringRef) @\"test.iusealocaltestserver.com\", 5060, &myReadStream, &myWriteStream); CFReadStreamSetProperty ( myReadStream, kCFStreamNetworkServiceType,