1

My project already uses ARC, however I added a class from apple that doesn't use ARC.

Can I refactor only this file to ARC? Selecting the class in the refactor menu, tries to compile my whole app without ARC. This will of course fail, as only one of the classes is non-ARC.

If there is no easy way to do this, can I compile this class without ARC?

Tyilo
  • 25,959
  • 32
  • 101
  • 183
  • 1
    You can flag individual files to not use ARC, [here](http://stackoverflow.com/questions/6646052/how-can-i-disable-arc-for-a-single-file-in-a-project). Also when refactoring Xcode gives you a preview of what files will be translated to ARC, so you can check those too. – ohr Sep 11 '12 at 23:14
  • @Comradsky you posted the same link as ohr. – Tyilo Sep 11 '12 at 23:32
  • @Tyilo thats funny, i will just delete my post then, but do look at that site – Comradsky Sep 11 '12 at 23:33

1 Answers1

1

This class is almost for sure in an Apple project. Refactor the whole project - you don't need to really finish or compile - but once done, you can then take the refactored file as a starting point.

David H
  • 39,114
  • 12
  • 86
  • 125
  • OK, but this file contains like 50+ places where I need to manually click the auto-fix red button and select insert `__bridge`. Can this be automated? – Tyilo Sep 11 '12 at 23:45
  • Can you tell me what project? I have converted lots of Apple source never saw this problem in auto convert. In any case, if you can get it to convert, you can then take the file, add it to your project, then run Analyze - which will report back any incorrect __bridge statements (in my experience in any case). – David H Sep 11 '12 at 23:52
  • Oh, I have found the ARC version of it and it was indeed made by you! The class I was looking for was KeychainItemWrapper, which you have ported to ARC here: https://gist.github.com/1170641 – Tyilo Sep 11 '12 at 23:55
  • Hah! I'm sure I didn't get 50 errors but it was a while ago. That code has held up pretty well - lots of people took it and no reported problems. I'm using it too in a few apps :-) – David H Sep 11 '12 at 23:56