iOS How to modify source in ARC?

jnoxx

macrumors 65816
Dec 29, 2010
1,343
0
Aartselaar // Antwerp // Belgium
You can do it easier.
Go to your Proejct, go to your target, then "Build Phases" Tab, then to the Compile Sources ->
Find the code files of the library you are trying. and double click on it, you will be able to insert compiler flags.
Type in here
Code:
 -fno-objc-arc
If you add that, it won't try to do ARC compiling on these files :)
Or you can just convert the files to ARC with the build in ARC-Converter ;p
 

mikezang

macrumors 6502a
Original poster
May 22, 2010
772
1
Tokyo, Japan
You can do it easier.
Go to your Proejct, go to your target, then "Build Phases" Tab, then to the Compile Sources ->
Find the code files of the library you are trying. and double click on it, you will be able to insert compiler flags.
Type in here
Code:
 -fno-objc-arc
If you add that, it won't try to do ARC compiling on these files :)
Or you can just convert the files to ARC with the build in ARC-Converter ;p
Thanks, I did it but I found the warning is due to static analyzer as below:
 

Attachments

idelovski

macrumors regular
Sep 11, 2008
235
0
The problem with directions looks strange at first because I don't have all of the code, but the second problem is related to ARC and he needs to use one of those bridging casts for objects created with CoreFoundation. Maybe __bridge_retained in this case, but I still don't use ARC so I'm not sure.
 

PhoneyDeveloper

macrumors 68040
Sep 2, 2008
3,114
93
The analyzer is complaining that the method returns an owned object rather than an autoreleased object but the name of the method doesn't indicate that it's returning an owned object. This isn't related to ARC.

Is the returned path CFReleased somewhere else in the code? If so you could fix this by changing the name to start with new.

UIBezierPath is similar to CGPath and the code could probably be rewritten to use UIBezierPath without much difficulty. If so it would then use Cocoa memory management and not CF memory management. I don't think CGPath is toll-free-bridged with an Objective-C class so there isn't a one-line change for this.
 

idelovski

macrumors regular
Sep 11, 2008
235
0
The analyzer is complaining that the method returns an owned object rather than an autoreleased object but the name of the method doesn't indicate that it's returning an owned object. This isn't related to ARC.

Is the returned path CFReleased somewhere else in the code? If so you could fix this by changing the name to start with new.
Strange, I was sure ARC would let you use CF objects, you only need to use one of those casts, like __bridge_retained or __bridge_transfer. Here the path is created with the call to CGPathCreateMutable() and since he can't change the name of that function what else could he do?
 

idelovski

macrumors regular
Sep 11, 2008
235
0
Well, seems like I misinterpreted intentions of the method on those three images. It was actually expected to return a new retained object and not autoreleased one. Since the word 'create' is not one of those magic keywords (new, alloc, copy and mutableCopy) he really needs to change the method name so it starts with 'new'.

Must admit I have several methods that do exactly the same thing: They start with the word create and return - what else but CGPathRef. Now I see why were you talking about toll-free bridging. In order to autorelease it I would need an equivalent cocoa object. Ah. Now I need to change those method names in my own code.

And now I see where I picked the habit of using such naming convention: Programming with Quartz. They do it all the time. All the functions that create new CoreGraphics objects start that way. As I was converting them into Obj-C methods I kept the similar name and now I have the problem.
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.