LoginSignup
2
2

More than 5 years have passed since last update.

プログラムメモ[2014/09/16]

Last updated at Posted at 2014-09-16

今,必要な物

NAS Access Framework

今回作成するプログラムでは,Sambaサーバーに接続する必要があるが,
小生の今の技量,知識では,締め切りまでには間に合いそうにないので,
フレームワークを使わせていただくことにした.
今回使うフレームワークは,Digital Art Corporation様が提供している
NAS Access Frameworkである.
テクニカルメールサポートを使わなければ,無料で使うことが出来るため,非常に有り難い.
また,サンプルプログラムなども付属しているため,小生のような貧弱プログラマーにも優しい.
本格的な実装には,移っていないが,サンプルコードをちょこっといじって遊ばせてもらっている.

カラーピッカー

今回作成するプログラムでは,色を選択し,その色をRGB値に変換して送る必要があるのだが,如何せん,小生の思う色を選びやすいUIのコードを書くことが出来ない.
なので,こちらもサンプルコードを使わせていただくことにした.
残念ながら,どれを使わせてもらうかは,まだ決めていない.
決めたら,更新するつもりだ.

Socket通信(TCP通信)

こちらは,順調に進んでいる.
今日中には,テキストを終わらせる予定である.

今日の躓き

プログラミングしてるときに,起きたエラーや思いがけない動作の原因を書くことで,また今度その問題にぶつかったときに,すぐに解決できる様にメモを残す.

Xcode5でのxib

Empty Applicationを作成し,projectにCocoaTouch Objective-Cクラスを追加する.
Class名は各自で決め(ここでは,ViewControllerとする),Subclass ofをUIViewControllerにし,Also create XIB fileのチェックを入れる.
これで,xibファイルとそれの実装ファイル,ヘッダーファイルが作成される.

次に,追加したxibファイルが起動したときに表示するようにさせるため,
もともとEmpty Applicationを作成したときに作られているAppDelegate.m(もしくは,AppDelegate.h)に先ほど作ったヘッダーファイル(ViewController.h)をimportさせる.
続いて,
AppDelegate.mのapplicationメソッドに下記のコードを加える.

    // ViewControllerの部分は,場合ごとに変更
    ViewController *viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
    self.window.rootViewController = viewController;

AppDelegate.mの全体は,このようになる

AppDelegate.m
#import "AppDelegate.h"
#import "ViewController.h" //追加したヘッダーファイル(名前は各自で変更)

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];

    // ここから(ViewControllerの部分は,各自付けた名前に変更すること)
    ViewController *viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
    self.window.rootViewController = viewController;
    // ここまで追加



    return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application
{
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application
{
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application
{
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application
{
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application
{
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end

こうすることによって,xibが表示されるようになるはず.

AppDelegate

調べてる途中なので,URLだけ貼っておきます.
見た感じだと,AppDelegateが鍵を握りそう

参考URL
AppDelegateに宣言した変数に別クラスからアクセスする方法 | Guttyo blog

OSゆとりプログラミングのススメ
AppDelegate をちょくちょく呼び出すためにすること

2
2
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
2
2