AsyncUdpSocket for ARC?

350 views
Skip to first unread message

Hadmut Danisch

unread,
Jan 3, 2012, 6:34:10 PM1/3/12
to cocoaasy...@googlegroups.com
Hi,

just a minor question:

I tried to use the async sockets for UDP sockets with ARC under iOS5
sdk, but ran into the problem that the arc branch does not contain the
UDP class, and the master branch's AsyncUdpSocket and GCDAsyncUdpSocket
do not compile with ARC and regular compiler settings. It's not just
simple changes of pointer handling. The compiler also complains about
some gotos, that jump over variable declarations and thus break the ref
counting.

I'm currently a beginner with iOS programming and busy with getting used
to it, so I'm not yet really familiar with every detail of the former
and the new memory management model. My assumption is that the main
changes will be to replace methods like retain, release with simple
pointer assignments, but replacing the gotos would require changes in
the program's logic and flow.

Is anyone more experienced with iOS and the asyncsocket library planning
to make a ARC version of the UDP socket?


best regards
Hadmut

Sean McBride

unread,
Jan 4, 2012, 5:57:27 PM1/4/12
to cocoaasy...@googlegroups.com, Hadmut Danisch
On Wed, 4 Jan 2012 00:34:10 +0100, Hadmut Danisch said:

>I tried to use the async sockets for UDP sockets with ARC under iOS5
>sdk, but ran into the problem that the arc branch does not contain the
>UDP class, and the master branch's AsyncUdpSocket and GCDAsyncUdpSocket
>do not compile with ARC and regular compiler settings. It's not just
>simple changes of pointer handling. The compiler also complains about
>some gotos, that jump over variable declarations and thus break the ref
>counting.

I haven't tried the ARC branch, but CocoaAsyncSocket doesn't need to support ARC to work in an ARC application. ARC apps can use manual ref counted code, just add -fno-objc-arc to any files that aren't ARC.

--
____________________________________________________________
Sean McBride, B. Eng se...@rogue-research.com
Rogue Research www.rogue-research.com
Mac Software Developer Montréal, Québec, Canada


Hadmut Danisch

unread,
Jan 4, 2012, 6:19:15 PM1/4/12
to Sean McBride, cocoaasy...@googlegroups.com
Am 04.01.2012 23:57, schrieb Sean McBride:
> I haven't tried the ARC branch, but CocoaAsyncSocket doesn't need to support ARC to work in an ARC application. ARC apps can use manual ref counted code, just add -fno-objc-arc to any files that aren't ARC.

Yeah, I've seen that somewhere, but I'm not sure whether it is a good
idea to mix code with and without that flag. I always prefer the clean
version over the workaround. And for the TCP socket, there is for some
reason a separate arc version. So maybe the UDP version is under
construction as well...


regards

Mike

unread,
Jan 4, 2012, 9:21:24 PM1/4/12
to cocoaasy...@googlegroups.com
Could you please point to the ARC version?
It seems to me that all the files are the same.

> --
> You received this message because you are subscribed to the Google Groups "CocoaAsyncSocket" group.
> To post to this group, send email to cocoaasy...@googlegroups.com.
> To unsubscribe from this group, send email to cocoaasyncsock...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/cocoaasyncsocket?hl=en.
>

Jan C.

unread,
Jan 18, 2012, 8:55:11 AM1/18/12
to CocoaAsyncSocket
ARC works during compilation not during runtime so it is perfectly ok
to mix ARC and non ARC code. Basically, with ARC, the compiler will
itself insert retain/realease calls into your code before actually
compiling

cheers ;)
Reply all
Reply to author
Forward
0 new messages