2008-02-02
■ [XCode]デバッグシンボルを認識しないとき。
External Target選択時のお話。
XCode Preference -> debug -> Load symbols lazily
デバッグの環境設定で、「CFMを使わないでシンボルを読み込む」をはずす。
http://d.hatena.ne.jp/RNatori/20080101#1199167404
http://www.cocoabuilder.com/archive/message/xcode/2007/12/6/17972
http://macresearch.org/tutorial_building_configure_make_projects_in_xcode
2008-01-06
■ [Cocoa][Objective-C]メモリ確保について調査。
http://homepage.mac.com/mkino2/spec/optimize/allocation.html
写経です。
allocation.m
#import <Foundation/Foundation.h> @interface Bar : NSObject { } @end @implementation Bar @end @interface Foo : Bar { int value; } @end @implementation Foo - (NSString *)description { return( [NSString stringWithFormat:@"%@ value=%d", [super description], value] ); } @end int main( void ) { NSAutoreleasePool *pool; unsigned int obj[2]; pool = [[NSAutoreleasePool alloc] init]; obj[0] = (int)[Foo class]; obj[1] = 2; NSLog( @"Using obj as a Foo object; %@", (id)obj ); [pool release]; return 0; }
% gcc allocation.m -framework Foundation && ./a.out
2008-01-06 11:32:04.626 a.out[20996:10b] Using obj as a Foo object; <Foo: 0xbfffea44> value=2
参考リンク
Q: malloc(0) は何をするものですか?free(NULL) とは何ですか?
2008-01-05[Cocoa]gnuglue.m
http://www.opensource.apple.com/darwinsource/10.0/Chess-45/gnuglue.m
NSString *copyright_text ()
{
NSBundle *bundle = [NSBundle mainBundle];
NSString *path = [bundle pathForResource: @"COPYING" ofType: nil];
if( path ) {
NSString *string = [NSString stringWithContentsOfFile: path];
if( string )
return string;
}
return nil;
}
NSString *user_fullname ()
{
struct passwd *pwen = getpwuid( getuid() );
return [NSString stringWithCString: (const char *) pwen->pw_gecos];
}
2007-11-25
■ [Objective-C++][C++]テンプレート
C++のテンプレートとObjective-Cを混ぜてみる。
なれるまで時間がかかりそう。
% g++ objc_plusplus_test1.mm -framework Foundation && ./a.out
#import <Foundation/NSObject.h> #import <stdio.h> template <class T> const T & min( const T &a, const T &b ) { return a < b ? a : b; } template <class T> const T & max( const T &a, const T &b) { return a > b ? a : b; } @interface Foo : NSObject - (void)printMax; - (void)printMin; @end @implementation Foo - (void)printMax { printf( "%d\n", max(1, 3) ); printf( "%f\n", max(1.0, 4.0) ); } - (void)printMin { printf( "%d\n", min(-1, 3) ); printf( "%f\n", min(-1.0, 4.0) ); } @end int main( void ) { Foo * obj = [Foo alloc]; [obj printMax]; [obj printMin]; return 0; }
■ [CotEditor][CodeReading]クラス関係など
CotEditorというオープンソースなエディタの存在を知ったので、
ちょっとだけ CodeReading してみる。
OgreKitを使用しているようですな。
grep 'CE.*:' *.h | uniq | sort | awk '{ $1=""; print }'
CEATSTypesetter : NSATSTypesetter CEAppController : NSObject CEApplication : NSApplication CEDocument : NSDocument CEDocumentController : NSDocumentController CEEditorView : NSView CEFlippedView : NSView CEHCCManager : NSObject CEHexColorTransformer : NSValueTransformer CEKeyBindingManager : NSObject CELayoutManager : NSLayoutManager CELineNumView : NSView CENavigationBarView : NSView CEOutlineMenuButton : NSPopUpButton CEOutlineMenuButtonCell : NSPopUpButtonCell CEPrefEncodingDataSource : NSObject CEPreferences : NSObject CEPreferencesTabController : NSObject CEPrintView : NSTextView CEScriptManager : NSObject CESplitView : NSSplitView CEStatusBarView : NSView CESubSplitView : NSView CESyntax : NSObject CESyntaxManager : NSObject CETabItemView : NSView CETextSelection : NSObject CETextViewCore : NSTextView CEToolbarController : NSObject CEWindowController : NSWindowController <OgreTextFindDataSource>