tag:blogger.com,1999:blog-34442452.post7221250300129278830..comments2023-04-16T03:49:21.961-07:00Comments on Cocoa Samurai: Clang Source AnnotationsColin Wheelerhttp://www.blogger.com/profile/16010768305821496589noreply@blogger.comBlogger5125tag:blogger.com,1999:blog-34442452.post-38724391276844571182012-02-03T10:16:00.573-08:002012-02-03T10:16:00.573-08:00Just to clarify, all my code now uses ARC. The Cla...Just to clarify, all my code now uses ARC. The Clang SA triggered this issue under ARC, even though we don't 'retain' anything in ARC now really, the Clang SA still uses the retained wording which here we really just mean, this was malloc'd essentially and needs to be freed at some point and since this is a Core Foundation style object you need to do it yourself.Colin Wheelerhttps://www.blogger.com/profile/16010768305821496589noreply@blogger.comtag:blogger.com,1999:blog-34442452.post-43963360925344746052012-02-03T08:18:09.365-08:002012-02-03T08:18:09.365-08:00If he were using ARC he would not see this warning...If he were using ARC he would not see this warning at all. In non-ARC you should auto release rather than using the annotation since that doesn't place extra burden on the caller and stays consistent with the naming guidelines.Mike Wellerhttps://www.blogger.com/profile/07165673241751830326noreply@blogger.comtag:blogger.com,1999:blog-34442452.post-22542733509639214822012-02-01T06:20:51.822-08:002012-02-01T06:20:51.822-08:00From clang docs
Methods in the alloc, copy, mutab...From clang docs<br /><br />Methods in the alloc, copy, mutableCopy and new families implicitly return a retained object as if they were annotated with the ns_returns_retained attribute. <br /><br />A selector is in a certain selector family if, ignoring leading underscores, the first component of the selector either consists entirely of the name of the method family or it begins with that name Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-34442452.post-42502799529451410472012-02-01T05:30:10.864-08:002012-02-01T05:30:10.864-08:00@missive: I'm curious as to how your code woul...@missive: I'm curious as to how your code would look then, as calling [foo autorelease] is forbidden under ARC.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-34442452.post-7600382495386097992012-01-31T22:24:01.805-08:002012-01-31T22:24:01.805-08:00This is actually bad practice; you're abusing ...This is actually bad practice; you're abusing that annotation. Clang is trying to tell you something. Everything returned from an ObjC method not named init, copy, or new should be autoreleased, including CF objects. Just cast it to id and invoke autorelease on it.Unknownhttps://www.blogger.com/profile/16859811372058858095noreply@blogger.com