0

I am adding the SoundCloud API to an iOS project and I am not using ARC. The SoundCloud code uses

@property(nonatomic, strong, readonly) NSArray *accounts;

Should I just change this to

@property(nonatomic, retain) NSArray *accounts;

and carry on with GCC or should I change to the LLVM compiler?

Is there anything else to change if I go with the GCC route, I'm not 100% on how either option effects the project? Is it simply the change like above?

Philipp Schlösser
  • 5,179
  • 2
  • 38
  • 52
some_id
  • 29,466
  • 62
  • 182
  • 304

2 Answers2

5

I think the correct thing to do here is to enable ARC on the whole project and then disable it for all of your source code in this manner. This way, you don't mess with anything that shouldn't be messed with.

Community
  • 1
  • 1
Stavash
  • 14,244
  • 5
  • 52
  • 80
  • Great, I will do that thanks. A side note. Are developers in general moving towards ARC? I find myself liking manually managing the memory(well, the retain count at least). Are there performance benefits for using ARC? Doesn't it compile slower due to the detection and then insertion of the code? – some_id Jun 30 '12 at 21:15
  • The general thought is that humans are much more error-prone than machines. A pre-compiler that goes over your code in a consistent manner is much less likely to forget to release an object or release an object that shouldn't be for example. Also, don't forget that objective-c was originally a pre-compiler for SmallTalk - I don't think that compilation time is even a factor to take into consideration here. – Stavash Jun 30 '12 at 21:19
  • Yeah. The compile time isn't a factor. Was just wondering. :/ – some_id Jun 30 '12 at 21:24
  • 2
    You can enable ARC for an individual file using `-fobjc-arc` in the method linked above, rather than disabling ARC for all of your files. – mopsled Jun 30 '12 at 21:32
  • I still get the error after turning ARC on for the .m file. The error is still in the .h file. – some_id Jun 30 '12 at 22:48
1

Compiler type used to be more of a preference than anything, especially back in Xcode 3.x, but as with Xcode 4.x, and especially in later versions, LLVM and LLDB are the recommended compiler/debugger for any source code.

CLANG used to be sort of a slow moving crud-fest compared to GCC back in the good ol days. GCC was the compiler that everyone knew how to use, and it was speedy and accurate about binary generation. But CLANG has definitely caught up in recent years, both in compilation time, and binary thoroughness.

CodaFi
  • 43,043
  • 8
  • 107
  • 153
  • Informative thanks. I changed to LLVM and still get the issue though. – some_id Jun 30 '12 at 21:12
  • Really? That shouldn't happen... Change it to the second one. If you really disabled ARC for the whole project, strong is not available to you. – CodaFi Jun 30 '12 at 21:13
  • Thing is I just started adding the SoundCloud API to a non-ARC based project. There is ARC code in the API. I will try stavash's suggestion and link. Thanks. – some_id Jun 30 '12 at 21:16
  • Haha, True. The speed actually makes no difference. I guess I feel less in control of the memory when using ARC. – some_id Jun 30 '12 at 21:19