Hear a rumor that the new version of xcode is going to add the release statements for you.
So if I init something do I actually have to release it?
What you're referring to is called Automatic Reference Counting. ARC is a feature in recent versions of the LLVM compiler that will be included in a future version of Xcode. You have to specifically enable ARC to get the benefits from it, and it includes its own set of rules that you need to follow. Right now, unless you're compiling with a prerelease toolset, you need to do your own retains and releases. And even when the feature is released, you will need to specifically code for it — Xcode won't just helpfully correct your mistakes.
Related
I just started learning about mac application development by doing this tutorial https://developer.apple.com/librarY/mac/referencelibrary/GettingStarted/RoadMapOSX/books/RM_YourFirstApp_Mac/Articles/GettingStarted.html
I feel dumb because I am stuck on the very first step. It says to make sure that the "use automatic reference counting" checkbox is checked, but I don't even have that checkbox.
This is a screenshot from the tutorial:
and this is a screenshot from my laptop while following along with the tutorial:
Since I am not even yet sure what automatic reference counting is I feel stuck because I don't know if it is important or not. Does anyone know why this option is not shown in my xcode?
The quick version: automatic reference counting is now the default, so just go to the next step.
The longer version: That tutorial appears to be written using Xcode 4.4 in the examples. The current version of Xcode is 5.1, and Apple has made a bunch of changes between then and now, some cosmetic and some more substantial.
One of those changes is that automatic reference counting (ARC) is now the default choice for new projects. ARC is a method of memory management where the compiler and runtime work together to keep track of which objects are still in use, and release the ones which aren't. When this technology was first introduced, it had some rough spots, and so it made sense to make it optional.
Apple is really pushing everyone to use ARC for all projects, so they removed the checkbox in the create project dialog. I'm not sure when this happened; may have been Xcode 5.0 or 5.1.
All that said: the tutorial you're using was written for an earlier version of Xcode than you're using. The big concepts are all going to still apply, but you'll run into issues from time to time where the screenshots don't look the same or the options are slightly different. So take a deep breath and just go for it. :)
I am building my app using iOS 5.0 as base SDK and iOS 3.0 as deployment target.
I know I need to check for existence of methods and classes when I work with features that are not available in the earlier iOS versions, but lately I've lost a few hours on a problem just to discover I was calling a method not available in some iOS versions. I simply did not notice it was a new method and did no check before to call it. The app of course compiled with 0 errors and 0 warnings.
This is a big problem because if I forgot some other check somewhere in the app, I will not know it until I or, worst, some user will activate that specific part of code.
Maybe I am missing something, is there some compiler option I can set to detect the calls I make to methods not available in the iOS deployment target? How do you deal with such a problem?
This link might point you in the right direction. Supporting mutiple ios Versions in your apps. It explains how to deal with taking advantage of the newer ios features while maintaining backwards compatibility. Hope that helps.
The only way to check for compatibility with a prior version of iOS, currently, it to test the app on an old non-updated device running that version of the OS.
If you can't find a device that old, even just to borrow for short time, then there may not be a good buiness reason to set the Deployment target that low.
I am using Xcode 4.2 and building a game for iphone (from iOS 3.0 - 5.0). Does cocos2d support ARC? What modifications needs to be made to convert code written in previous versions?
If I use the strong and weak keywords for variables and set compiler to LLVM GCC 4.2, what will be the results? Is it a necessity to change compiler to 3.0 to support ARC?
Cocos2d v1.1 and v2.0 are compatible with ARC. However, the cocos2d code itself does not use ARC and there are no templates provided by cocos2d that you can use to start programming with ARC. You are required to add a seperate static library target for the cocos2d files yourself.
As Ankit pointed out, Tiny Tim Games made the necessary changes to a forked version of cocos2d-iphone to make it ARC compatible. These changes have been integrated into the development version and should be available in the cocos2d v2.x branch. I've since written a tutorial to enable ARC in a cocos2d (2.0) project.
It was said that cocos2d itself will be converted to use ARC internally in v2.1 or v2.2.
It's important to note that there are no plans to officially support ARC in the cocos2d v1.x branch because the v1.x line is supposed to remain backwards compatible with 1st generation devices and iOS 3.x. But general ARC compatibility has been added to v1.1.
Kobold2D fully supports ARC and has it enabled in all 15 template projects for almost two months now. Kobold2D uses the latest stable versions of cocos2d-iphone 1.x and 2.x. Just start a new Kobold2D project and you're set to work with cocos2d and ARC.
Even though Cocos2d does not support arc but there is way in which you can use both of them together, and that is by cross project referencing. You can learn how to do it by refering this.. cocos2d and ARC
Even easier, just get my cocos2d-ARC template here: https://github.com/Elland/Cocos2d-iphone-ARC-template hassle free, just rename the project to your desired name and you're set :)
I just released my app but I am only able to make it compatible from 4.3 and up.
When I try to go any lower than 4.3 (xcode), it says I need to add code to make this work.
Does anyone know how to do this or has any suggestions? I would like my app to be compatible with 3.0 and onwards.
Thank you very much
You have to reach the least common code, what I mean by this is that you must find all the methods that are all incompatible within all of these versions of the OS. After that you will have to find each and every of it's functional equivalents. Then you can use conditional statements to check for every version and see what fits better or you can use the respondsToSelector method inherited from the NSObject class. In the end you have to test it on each device you are targeting :P
You can run this checkup list that I have always liked.
Edit:
I think I misunderstood your question though it has already been mentioned, be sure to check your deployment target in your build settings.
Checklist:
In your project's build settings…
Did you set the "iOS Deployment Target" to iOS 3?
Did you include the armv6 architecture in both, the built and the valid architectures?
In general:
Do you link to any framework that is not supported on iOS 3?
Do you use any methods, classes or other features that have been added later?
I'm about to start a new project and I'm wondering whether I should use ARC or not.
I don't know if it's recommended to use ARC when I know that the new project will have quite a lot of dependencies on older code and external libraries which have not been converted to ARC yet (three20, shareKit, ASIHTTPRequest,..) ?
Some of the libs are quite big so I think it'll be tedious to add the -fno-objc-arc flag for each separate file.
It seems that Apple has went the ARC way definitely for IOS and every IOS developer will have to convert sooner or later.
But is it maybe just too early to jump on the ARC bandwagon yet ?
Compiled libraries will work with ARC out of the box. All ARC does is add the memory management automatically. It'll add the retains, releases etc. If the code is already compiled, it'll contain the necessary memory management, regardless of whether it was compiled with ARC or not.
If you're adding 3rd party code directly to your application, then you'll need to make sure that code works with ARC, but you don't need to change anything for compiled libraries and frameworks.
Apple are pushing ARC as the way forward, so for a new project, I don't think there should be any problems with using it.