FrontPage > Apple > iOS開発メモ > 開発メモ
nil | 「NULL」 Java、C#の「null」と同一 |
/* // NSLog関数 void NSLog (NSString *format, ...); */
FORMAT 説明 %@ NSStringインスタンス(id) %d or %D or %i 整数 %u or %U 整数 (符号なし) %x 16進数 (小文字) %X 16進数 (大文字) %f 浮動小数点 %c 文字 %s 文字列 %S 文字列 (Unicode) %% '%'(パーセント表示) ...他
// Logテスト1 NSLog(@"hoge"); // Logテスト2 NSLog(@"[%d]:%s", 1, @"aaaa");
「Objective-C」ではC言語と同じで「main関数」から起動されます。
#import <UIKit/UIKit.h> int main(int argc, char *argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; int retVal = UIApplicationMain(argc, argv, nil, nil); [pool release]; return retVal; }
自動開放用プールの生成処理
アプリケーションの開始処理
/* // UIApplicationMain関数 int UIApplicationMain ( int argc, char *argv[], NSString *principalClassName, NSString *delegateClassName ); */
「Info.plistファイル」には、「Main nib file base name」の他に、 「Main nib file base name (iPad)」、「Main nib file base name (iPhone)」と云う個別指定もある。
#import <UIKit/UIKit.h> @interface testAppDelegate : NSObject <UIApplicationDelegate> { UIWindow *window; } @end
#import "xxxxAppDelegate.h" @implementation testAppDelegate - (void)applicationDidFinishLaunching:(UIApplication *)application{ CGRect frameForWindow = [[UIScreen mainScreen] bounds]; window = [[UIWindow alloc] initWithFrame:frameForWindow]; // Label表示 CGRect rect = [window frame]; UILabel* label = [[UILabel alloc] initWithFrame:rect]; label.text = @"Hello"; [window addSubview:label]; [label release]; [window makeKeyAndVisible]; } - (void)dealloc { [window release]; [super dealloc]; } @end