0

Disable ARC for a single file in a project

-

It is possible to disable ARC for individual files by adding the

  1. -fno-objc-arc
-fno-objc-arc

compiler flag for those files.

You add compiler flags in Targets -> Build Phases -> Compile Sources. You have to double click on the right column of the row under Compiler Flags. You can also add it to multiple files by holding the cmd button to select the files and then pressing enter to bring up the flag edit box.

 

0

Migrating your code to Objective-C ARC

-

Recently, Apple introduced several new developer stuff including Xcode 4, ARC, LLVM Compiler 3.0 and iOS 5. From some of the questions on Stack overflow, I could understand that, most of the ARC related confusions arise due to the fact that, developers don’t know if “ABC” is a feature/restriction of LLVM 3.0 or iOS 5 or ARC.

Retain cycles, auto-release pools, @autorelease blocks, oh man! So many new things? What am I going to do? You are right. ARC, or Objective-C Automatic Reference Counting is almost as magical as the iPad. No really!

In this post, I’ve made an attempt to demystify the air around this. Before starting, I’ll have to warn you that, this is a fairly long post. If you are too bored, Instapaper this article and read it later. But, hopefully, at the end of this, I believe, you will have a better understanding on how ARC works and be able to work around the innumerable errors it spits out when you convert your project.

Having said that, let’s get started.

What is ARC

ARC is a feature of the new LLVM 3.0 compiler that helps you to write code without worrying much about memory management. Memory management can be broadly classified into two, garbage collected and reference counted models. Before going to the details, let’s briefly discuss these two models and understand why ARC is even needed.

(more...)

0

Objective-C Cheat Sheet and Quick Reference

-

Recently I taught an offering of iOS101 at 360iDev, which is a 1-2 day workshop on beginning iOS programming.

In the workshop, I like to cover the basics of Objective-C, since those new to iOS programming are usually also new to Objective-C.

In past offerings of iOS101, a common request was “please make an Objective-C cheat sheet for the workshop!”

Well, your wish is my command – keep reading to download the official raywenderlich.com Objective-C cheatsheet! :]

Show Me The Cheat Sheet!

Without further ado, here is the download link:

Objective-C Cheatsheet and Quick Reference

It summarizes the most important Objective-C syntax on one page to get you up to speed quickly, including:

  • Types and variables
  • Creating and using classes
  • Defining and implementing methods
  • Defining and synthesizing properties
  • Creating custom initializers
  • Handy methods in NSArray/NSString

Feel free to print out a copy or send to a friend who’s learning Objective-C! :]

More Cheatsheets!

If you like this cheat sheet, there are some other Objective-C cheat sheets out there you might like as well:

If you guys have any other cheat sheets or quick references to recommend to beginners, please join the discussion below.

Also, huge thanks to everyone who attended iOS101. I really enjoyed meeting you guys and hope to see some of your apps in the App Store! :]