はい、あなたがターゲットに基づく2つの異なるを作成することができますは、次のように変更します。
プロジェクトで
main.m
あなたは
int main(int argc, char *argv[])
{
@autoreleasepool {
NSString *appDelegateName;
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone){
appDelegateName = NSStringFromClass([AppDelegateIPhone class]);
} else {
appDelegateName = NSStringFromClass([AppDelegateIPad class]);
}
return UIApplicationMain(argc, argv, nil, appDelegateName);
}
}
ような何かを行うことができますしかし、IMO、あなたがやるべきではありませんそれ。
代わりに、Appleのようにアプリケーションのデリゲートで別のView Controllerまたは別のXIBをロードします。
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController_iPhone" bundle:nil] autorelease];
} else {
self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController_iPad" bundle:nil] autorelease];
}
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
@end
私は不思議ですが、なぜこれが欲しいですか? – Alexander
@AlexanderMomchliov私はコードをできるだけ別々にしておきたいのです。私の意見では、AppDelegateはアプリケーションの「エントリーポイント」なので、実際には非常に異なるアプリケーション(しかし、ライブラリとリソースを大量に共有する)間のターゲットを分離する必要があります。これは、AppDelegateを含む自分のフォルダ内のそれぞれのターゲットを整理し、別のプロジェクトに素早くコピーすることができるようにするためです。 –
非常に異なるアプリケーションが2つある場合は、2つの異なるプロジェクトにする必要があります。共有コードは、最初の2つから参照される第3のライブラリプロジェクトに抽出される必要があります。 – Alexander