Converting Apple's MVC Networking sample to ARC - objective-c

Has anyone converted the Apple MVC Networking sample to ARC?
http://developer.apple.com/library/ios/#samplecode/MVCNetworking/Introduction/Intro.html
As a new iOS developer I am very interested in ARC and attempted the conversion w/o success, sent a few emails to Apple, no response.
During the conversion there were some CF functions that I couldn't bridge correctly and there were all kinds of memory issues and exceptions.
Currently I don't have an example, just wanted to see if anyone else has been though the conversion, Google didn't help me out this time :)
Thanks

Just curious but why are you trying to do this conversion? If you are integrating this example into a project that already runs with ARC, you can exclude the source files that aren't ARC explicitly in the Compile Source section of your build phases in the Target.
If you want to try this, select the sources that don't have ARC and hit enter. A dialog should appear where you can enter:
-fno-objc-arc
Hope this helps.

XCode 4.3.2 has a new feature to convert projects to ARC.
Edit->Refactor->Convert to Objective-C ARC
Should get you going in no time!

Related

file browser for webdav ios7

I have been looking for a packet/library with a file browsing capability for WebDAV, which I could use for my project in objective c, using xcode 5.1. so far the best I have found is GDFileManagerKit. but it still has stuff unsupported by my ARC such as AFNetworking version used. I do not want to alt the code of this library since it requires many changes. I would like to know if there is a better library or without me having to use AFNetworking version 1.
Thank you and please bear with me if this question is very novice. I am new to objective c xcode and iOS
You could use one of several free libraries, for example WTClient. Yet, every library I have seen is not using ARC, instead managing memory without the garbage collector.

upgrading to Automatic Reference Counting and cleaning up my code

I have a project from 2 years ago that I'd like to bring back into action in xcode.
Is there a simple way to do away with the old style memory management I have in there with retain/releases and use the new .. ARM?
And this is a 32bit app using the QTKit and QuickTime frameworks - can this become a 64bit app that I can put on the App Store one day if it works well?
Also I realise that my app is one enormous .h and .m file - i'd like to break it into smaller files to make it easier to read and find what i am doing - any tips on how to do that?
Thanks guys!
Adam
Use the Xcode menu item Edit->Refactor->Convert To Objective-C ARC which can automatically convert everything to ARC.
You can also use Edit->Refactor->Convert to Modern Objective-C syntax to update the code to use the new array/dictionary/number literal syntax.
For breaking out one file into many, Xcode's built-in refacting support is pretty terrible. You can try out Jetbrains Appcode which has much better support for this kind of thing.

Debugging iOS app with gdb on jailbroken iPod touch | Objective-C Symbols

I'm looking to debug an app on a jailbroken iPod Touch 4, iOS (5.1.1) using. The only problem is GDB doesn't appear to have any knowledge of class/selector names for the app.
Attaching and setting address breakpoints work, but it cannot identify symbols when attempting to use objective-c names. For example, break -[Class Selector:] will fail. (I'm aware that + and - represent different class types.)
Also, I do not have the source for this app and will not be able to acquire it.
I'm looking to purely use GDB on the device without xcode or the source.
Has anyone successfully done this before? Thanks in advance for any answers.
Under the assumption that you're trying to debug an app from the store / a release build then your binary will have had the symbols stripped from it by the compiler. Only debug builds retain the symbols: there's no reason for release builds to keep them.
To find out the names you'll need to disassemble the binary manually and figure out what you need from there. This is a lengthy topic, too long to really type up in great detail here (O'Reilly's Hacking & Securing iOS Applications book has a good step by step tutorial).
Bear in mind that under the hood the Objective-C messaging framework is made up of C: if you're not familiar with things like the objc_msgSend series of functions you might find getting to know them better will help you along. Since every method invocation in Objective-C is sent using objc_msgSend you can effectively figure out class and method names by break-pointing every time it's called (or rather, breakpointing and automatically dumping the contents: it will be called so many times that to do it manually would take far too long).
However, this is only going to help you identify the symbol names: as the symbols are stripped from the binary you're still going to have to breakpoint on the addresses themselves.

ARC and ABAddressBook API for iOS

I have an app that uses the ABAddressBook API and I am trying to convert my app to use ARC.
I know the AddressBook API is written in native C and its giving me a lot of errors when ARC is enabled.
Anybody knows how to do it or is it even worth to do it?
Thanks in Advance.
One possible solution is to set compiler flags for the code that is giving you trouble to convert to. Go to Build Settings for the particular target you are using and add the flag "-fno-objc-arc" to the files that are problematic. Also, any more info on the actual problems arising would be helpful.
bartender,
First, working code is working code. You can easily intermix both kinds of memory management mechanisms in the same app. I only convert classes to ARC as I open the code up for other purposes. This allows me to slowly move my app to ARC. Why do you want to change this code to use ARC?
Second, the interface between core foundation items and ARC can appear to be complex ... but it isn't. Most issues are handled by using the __bridge type qualifier. Typically, the compiler/fix-it tells you exactly what you need to do. (Working, non-leaking CF code doesn't need to change. It just needs to tell ARC to leave it alone.)
Andrew

Is it too early to use ARC for new projects?

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.