Convert / Cast CFReadStreamRef to NSInputStream (iOS5)

I am trying to port my application to iOS5. I am using a TCP connection to the server through CFSockets. Now my problem is casting from CFReadStreamRef to NSInputStream (same with write). With iOS4, I could use a free bridge, but with iOS5 automatic link counting this is no longer possible. This is what I get:

error: Automatic Reference Counting Issue: Cast to 'NSInputStream *' of a non-Objective-C to an Objective-C pointer is disallowed with Automatic Reference Counting 

the code:

  CFReadStreamRef readStream; CFWriteStreamRef writeStream; CFStringRef strRef = CFStringCreateWithCString(NULL, [urlStr UTF8String], NSUTF8StringEncoding); CFStreamCreatePairWithSocketToHost(NULL, strRef, 4444, &readStream, &writeStream); NSInputStream *iStream = (NSInputStream *)readStream; NSOutputStream *oStream = (NSOutputStream *)writeStream; 

Is there any other way to connect socket output / input in NSStream? Thanks for any hint!

+2
ios5 network-programming release counting
source share
1 answer

The management of Toll-Free Bridging very clearly indicates that you should use something like this:

 NSInputStream *iStream = objc_unretainedObject(readStream); 
+2
source share

All Articles