I’m following a simple socket tutorial which is written without ARC in mind. I’m injecting the ideas from the tutorial into my app, which is all written with ARC enabled.
I’m running into a problem with this specific line of code:
CFStreamCreatePairWithSocketToHost(NULL, (CFStringRef)self.SERVER, self.PORT, &readStream, &writeStream);
which under ARC does not compile, so i tried both of the ‘fix-it’s’, one of which is:
CFStreamCreatePairWithSocketToHost(NULL, (__bridge CFStringRef)self.SERVER, self.PORT, &readStream, &writeStream);
however this line is causing me some issues. My app crashes on what seems like an internal call ‘objc_msgsend’giving me an exc_bad_access error.
Any ideas on how to fix this line for ARC?
edit: my debugging skills failed me before posting this. the cause of the problem is not the reason stated above but something else in my code. I think it has something to do with handling incoming streams.
Beside the naming convention for methods and properties, as Nikolai correctly pointed out, I suspect that your are not retaining your streams.
The should be declared as
strongif they are properties, can you please show the rest of your code?