1

I started new project in XCode 4.2 without "Automatic Reference Counting" and without "Use Storyboard".

I chose a "Single View App" in the app template selection.

My AppDelegate.h contains:

#import <UIKit/UIKit.h>

@class ViewController;

@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;

@property (strong, nonatomic) ViewController *viewController;

@end

But the strong value is allowed in iOS 4.x devices? If not how can I create apps for iOS4+ with the new XCode 4.2? Of course without downgrade XCode.

Thank you. Cheers.

Fred Collins
  • 5,004
  • 14
  • 62
  • 111

2 Answers2

3

Replace strong with retain since you're not using Automatic Reference Counting.

Koby
  • 7,267
  • 2
  • 21
  • 16
  • Thanks for the information. Is this the only change I need to apply for take care of iOS 4.x devices? – Fred Collins Nov 06 '11 at 16:42
  • No, assuming you're not going to use ARC with your 4.x application (it's possible, as it adds an ARC related library to your 4.x project when you turn it on), I would recommend watching the WWDC 2011 video specifically on Automatic Reference Counting as it covers the differences fairly well. – Koby Nov 06 '11 at 16:48
1

strong is allowed in iOS 4 applications (with ARC turned on) although you can use the old retain in your non-ARC project. An important setting is to set your Deployment Target to the lowest iOS version that you want to support (e.g. 4.0) and not to use any APIs that are not available in that version. Besides that everything should be fine and you can use Xcode 4.2 to develop iOS 4 compatible apps.

Dennis Bliefernicht
  • 5,147
  • 1
  • 28
  • 24
  • Thanks. But should I remove `@autoreleasepool { return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); }` in main.m? – Fred Collins Nov 06 '11 at 16:47
  • The llvm compiler seems to allow the @autoreleasepool as per http://clang.llvm.org/docs/AutomaticReferenceCounting.html#autoreleasepool (link from http://stackoverflow.com/questions/7950583/autoreleasepool-without-arc/7950636#7950636) so this should be fine. – Dennis Bliefernicht Nov 06 '11 at 16:56
  • In that post the guy says is allowed from iOS 5.0. – Fred Collins Nov 06 '11 at 16:58
  • I interpreted the message (referred from Twitter post https://twitter.com/#!/gparker/status/126596801481547776) as "always works" (i.e. also on iOS 4) but is faster when deployed on iOS 5. – Dennis Bliefernicht Nov 07 '11 at 00:45
  • Yea, that's the message, but it actually doesn't work below iOS 5.0. I tested it ;-) – tamasgal Apr 09 '12 at 01:11