0

Possible Duplicate:
Some questions about Automatic Reference Counting in iOS5 SDK

Well, that's about it.

Does any one support automatic garbage collection? Which ones?

Which iOS versions let you develop without managing memory yourself? (i.e., only using Automated Garbage Collection)

Community
  • 1
  • 1
Pablo Marambio
  • 1,562
  • 1
  • 15
  • 29
  • 2
    Are you referring specifically to ARC? – Greg Hewgill Oct 12 '12 at 19:57
  • possible duplicate of [Some questions about Automatic Reference Counting in iOS5 SDK](http://stackoverflow.com/questions/6368600/some-questions-about-automatic-reference-counting-in-ios5-sdk) and http://stackoverflow.com/questions/8312056/ios-automatic-reference-counting – adarshr Oct 12 '12 at 19:58

1 Answers1

5

It doesn't primarly depend on the version of iOS. It depends on the version of the compiler. ARC is supported in clang with LLVM version 3.0 and later.

Unfortunately enough, however, iOS 4.2 and earlier is missing symbols that are used by the compiler to generate ARC-enabled code, so these versions can't support ARC. This is not a strictly technical dependency though - if the clang compiler was written so that it doesn't require extra functions to generate ARC code, persumably all previous versions of iOS could run programs written using ARC.

  • Do clang versions map to iOS versions in any way? – Pablo Marambio Oct 12 '12 at 20:00
  • @PabloMarambio of course it doesn't. –  Oct 12 '12 at 20:01
  • 2
    They don't, but anyway iOS 5+ is the future now, more than 95% of the market is using it, so there really is no point in developping without ARC anymore, unless you need to do some advanced stuff. – F.X. Oct 12 '12 at 20:01
  • @F.X. well, I always try to avoid ARC, it's a mess. Personally, I prefer MRC. It can be compiled by more compilers. Anyway, this is not related to iOS 5. –  Oct 12 '12 at 20:04
  • Also, you should at least be a little aware of what's happening behind the hood : ARC is no magic, it only inserts calls to `retain` and `release` by itself, and sometimes you have to be extra careful -- retain cycles, weak pointers, stuff like that. – F.X. Oct 12 '12 at 20:04
  • @FX, are you suggesting a relationship between ARC and iOS versions? – Pablo Marambio Oct 12 '12 at 20:04
  • 1
    @PabloMarambio : In some ways yes. See http://stackoverflow.com/questions/7747783/is-arc-really-supported-in-ios-4-the-ios-4-2-sdk-is-missing-arc-related-symbols for more information. – F.X. Oct 12 '12 at 20:05
  • 1
    Note that this answer is only partially correct. ARC has features (weak references) that are not compatible with iOS4 even though iOS4 supports most other ARC features. – Till Oct 12 '12 at 20:06
  • 1
    @F.X. apart from the technical details, this is not a strong relation or a particular feature of the OS. It's just rather a result of bad compiler design. –  Oct 12 '12 at 20:06
  • 3
    @Till Right, I updated my answer, though I'm starting to bang my head into the desk because of Apple having written their c(rap)ompiler like this... –  Oct 12 '12 at 20:09
  • @H2CO3: If you're staying behind XCode and all the tools put in place by Apple, then my opinion is that ARC is way better, _if_ you understand what's happening, and especially for UI-related tasks. But then if you want to share code between compilers/projects, make libraries or other more advanced things, _then_ you might want to avoid ARC because it doesn't play very well with non-Apple stuff. Again, depends on your preferences ;) – F.X. Oct 12 '12 at 20:10
  • Anyway, the answer seems to be **"iOS 4.3 and later"** – Pablo Marambio Oct 12 '12 at 20:11
  • 3
    @F.X. I'm a Cydia developer having used an opensource Linux toolchain (until I received my MacBook, recently). :) Now you know what I mean. (And yes, I can't stand people not knowing a single word about MRC, confusing Xcode with Objective-C with iOS with Cocoa Touch with the compiler, and writing badly designed and badly formatted code which is evlolving to finally end up being a mess...) –  Oct 12 '12 at 20:14
  • @H2CO3: Ah, yeah, "advanced" uh? That's more on the "guru" level :D Anyway, I guess this is getting a little out of topic, so, yeah, the answer is **"iOS 4.3 and later, but preferably iOS 5"** :) – F.X. Oct 12 '12 at 20:21
  • @F.X. Well, this is rather the 'how-normally-it-should-be-and-people-not-knowing-this-should-not-be-permitted-to-write-iOS-apps' level IMHO :) The real gurus are the guys in the Dev-Team or alike ;-) –  Oct 12 '12 at 20:24
  • 1
    @H2CO3: ARC's limitations on iOS4 don't have anything to do with the compiler. Features were added to the Objective-C runtime on iOS 5 that enabled weak pointers (the only feature not available on iOS4). – Jon Shier Oct 12 '12 at 20:30
  • 1
    @jshier you're missing the context here :) Again, this may count. And maybe many more factors (gradually less and less important, respectively). But this is the most important part - nobody really cares about the Obejctive-C runtime until it didn't even have a chance to start since `dyld` terminated the app due to unresolved symbols... –  Oct 12 '12 at 20:32
  • @H2CO3: 90% of the iOS devs never went through the trouble of installing an open-source toolchain though, myself included. Anyway, why worry about iOS 4.3 since (almost) nobody uses it anymore? :) – F.X. Oct 12 '12 at 20:36
  • 1
    @F.X. FYI, until recently also, I only had an iPhone 3G. Now go see what is the highest version of iOS it supports :) Then how on Earth could I have tested my apps & tweaks without a device? –  Oct 12 '12 at 20:45
  • @H2CO3: I'm just pointing out that your comments about crap compiler design and asserting it's because of clang that ARC doesn't have weak references on iOS4 is completely off base. – Jon Shier Oct 12 '12 at 20:50
  • @jshier Then flag those comments as off-topic! The answer is right as-is. :) –  Oct 12 '12 at 20:52