2012-06-12 74 views
0

這裏是情況。我在xcode 4.2中創建了一個項目,部署目標設置爲5.0。但我想給我的代碼向後兼容到4.0。現在我沒有4.2或4.0在xcode 4.2模擬器,所以我運行我的代碼在xcode 4.0。在這裏,我得到了兩個錯誤:運行在xcode 4.0(部署目標4.0)中的xcode 4.2(部署目標5.0)中創建的項目

1. unknown "strong". I removed it by adding retain instead. 
    2. unknown "@" in project, so I added below code in main.h 

NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 
int retVal = UIApplicationMain(argc, argv, nil, nil); 
[pool release]; 
return retVal; 

這就是我們通常在main.h寫道ARC或iOS5的

之前,現在我遇到的是main.h漸漸叫,但AppDelegate中沒有得到另一個問題稱爲即aplicationDidFinishLaunching從未被調用。然後我修改了上面的代碼是這樣的

NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 
int retVal = UIApplicationMain(argc, argv, nil, NSStringFromClass(AppDelegate.class)); 
[pool release]; 
return retVal; 

現在,我沒有問題,構建是成功的,它得到在Xcode的兩個版本編譯。我只是想知道爲什麼會發生這種情況,並且可以繼續使用xcode 4.2中的上述主要定義繼續我的項目,因爲它對我來說似乎並不好。

回答

0

嘗試this。這應該回答你的問題。

基本上你需要首先瞄準iOS4,它應該與iOS5一起工作。問題在於當你從iOS5開始時,因爲iOS4不知道新功能。這可能看起來很痛苦,但考慮是否有必要支持iOS4,我們現在有iOS6,iOS5是所有版本中的大多數......