FrontPage > Apple > iOS開発メモ > 開発メモ

開発メモ

nil「NULL」 Java、C#の「null」と同一


デバッグ

NSLog関数

/*
// NSLog関数
void NSLog (NSString *format, ...);
*/
FORMAT説明
%@NSStringインスタンス(id)
%d or %D or %i整数
%u or %U整数 (符号なし)
%x16進数 (小文字)
%X16進数 (大文字)
%f浮動小数点
%c文字
%s文字列
%S文字列 (Unicode)
%%'%'(パーセント表示)
...他
// Logテスト1
NSLog(@"hoge");
// Logテスト2
NSLog(@"[%d]:%s", 1, @"aaaa");

起動順序

main.m

「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;
}

NSAutoreleasePool関数

自動開放用プールの生成処理

UIApplicationMain関数

アプリケーションの開始処理

/*
// UIApplicationMain関数 
int UIApplicationMain (
   int argc,
   char *argv[],
   NSString *principalClassName,
   NSString *delegateClassName
);
*/

xxxxAppDelegate.h

#import <UIKit/UIKit.h>

@interface testAppDelegate : NSObject <UIApplicationDelegate> {
    UIWindow *window;
}
@end

xxxxAppDelegate.m

#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

トップ   編集 凍結 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2010-07-13 (火) 17:13:02