19
19

More than 5 years have passed since last update.

xcode複数人開発(1)

Posted at

今後xcodeで複数人開発をする可能性があるので、チーム開発の際の注意点みたいなモノをメモっておきます。
本番環境で試したわけではないので、もっといい方法とかあったら教えて下さい。

ざっくりした環境

github
xcode
iOSアプリ開発

Storyboardについて

iOSアプリのチーム開発においてStoryboardの干渉をよく耳にします。
GUI上でパーツを操作する事が前提のStoryboardで*行目をマージする…と言った操作を人間が行うのは非常に危険かと思います。
複数人で開発する際は開発者ごとにStoryboardを用意して、ViewControllerごとに開発を行うと良いと思いました。
Storyboardを複数に分ける上で問題になるのは画面の遷移かと思います。
元々Storyboardはxibのview画面構築をUIViewControllerに拡張子、画面遷移をプラスした機能なのでやや旨味がなくなってしまいますが、少し複雑なアプリになるだけでStoryboardは矢印だらけになってすぐカオスになるのでいっその事Stoyboard上での画面遷移はやめてしまったほうが得策かと思います。

コード上での画面遷移

以下の例は
Main.storyboardにDetailというidentifierのついたVCが登録されている場合の例です。

    UIStoryboard*storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
    UIViewController*vc = [storyboard instantiateViewControllerWithIdentifier:@"Detail"];
    [self presentViewController:vc animated:true completion:nil];
    //pushの時
    //[self.navigationController pushViewController:vc animated:true];

それぞれ分割して説明すると、

    UIStoryboard*storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];

でStoryboardのインスタンスを生成します。
ここはだいたいのチュートリアルでは

    [self.storyboard ~

と書かれている部分です。
self.storyboardで自分のViewControllerのstoryboardインスタンスを取得しますが、今回の場合他の開発者が管理しているViewControllerを取得する可能性があるのでselfではなくしっかりとStoryboardのファイルを指定してあげます。

    UIViewController*vc = [storyboard instantiateViewControllerWithIdentifier:@"Detail"];

ここでStoryboardのインスタンスからViewControllerを取得します。
UIViewController*vcとしていますが、delegateやpropertyへのアクセスが有る場合(がほとんどだと思いますが)はDetailViewController*vc等クラスで宣言してあげてください。
因みに@"Detail"の部分はStoryboardでViewContollerを選択し、Identity>Storyboard IDで指定出来ます。(指定しないと落ちます。注意!)

    [self presentViewController:vc animated:true completion:nil];

Storyboardで言う画面遷移がこの部分にあたります。

19
19
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
19
19