Recently in Macintosh Category

AppKit 一点笔记(三)

| No Comments | No TrackBacks
程序如何运行?
  入口main函数
  
#import <Cocoa/Cocoa.h>
 
int main(int argc, char *argv[])
{
    return NSApplicationMain(argc,  (const char **) argv);
}
  
应用程序主进程开启
 通过Info.plist 查找 NSMainNibFile,并load之
NSMainNibFile 文件Load完成后,下一步NibFile中"File's owner' 回调用awakeFromNib
10.6 之后支持[super awakeFromNib]

程序启动完成

程序状态管理和维护通过

NSApplication,NSApplicationDelegate 

NSNibLoading,单独load

使用NSBundle 3个方法

  

+ (BOOL)loadNibFile:(NSString *)fileName externalNameTable:(NSDictionary *)context withZone:(NSZone *)zone;

+ (BOOL)loadNibNamed:(NSString *)nibName owner:(id)owner;

- (BOOL)loadNibFile:(NSString *)fileName externalNameTable:(NSDictionary *)context withZone:(NSZone *)zone;


看起来第二个更简单些

  


另外Document base Application NSDocument 类可以使用

- (NSString *)windowNibName;方法加载目标Nib文件


NSWindowController 同样可以使用上面的这个方法


AppKit 一点笔记

| No Comments | No TrackBacks

NSWindowController

- (id)initWithWindow:(NSWindow *)window

或者使用 - (NSString *)windowNibName

NSWindowController *controller = [[c alloc] init];

    if (_windowControllers == nil) {

        _windowControllers = [NSMutableArray new];

    }

    [_windowControllers addObject:controller];

    [controller showWindow:self];//显示Window,self 为NSWindowController

    [controller release];


注册窗口关闭通知

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_windowClosed:) name:NSWindowWillCloseNotification object:nil];


处理关闭窗口通知,移出不需要的Window

- (void)_windowClosed:(NSNotification *)note {

    NSWindow *window = [note object];

    for (NSWindowController *winController in _windowControllers) {

        if (winController.window == window) {

            [[winController retain] autorelease]; // Keeps the instance alive a little longer so things can unbind from it

            [_windowControllers removeObject:winController];

            break;

        }

    }

}

Enhanced by Zemanta
日期:  11 月8日 下午2:00
地址:上海 长宁 万航渡路2453号 周家桥创意园B区
内容: iPhone 应用&游戏开发
       主题演讲1 游戏中使用OpenAL
dream2
上海骏梦网络科技有限公司 http://www.thedream.cc/ 
联系人:孔祥波  yarshure@gmail.com
打算学习AppleScript, Oreilly正好有本中文的书(《AppleScript权威指南(第二版)》)

看介绍不错:
AppleScript_tdg_cvr.jpg
"AppleScript就像一把瑞士军刀,帮助您利用您的苹果机的强大功能并控制整个系统以及运行于其上的应用程序。作者Matt Neuburg用一种前所未有的方式来教授AppleScript,全面而准确地给每个人(从普通的家庭用户到出版业的专业人士和系统管理员)创建脚本的 知识,来让您的苹果机做任何您需要它做的事情。"





屏幕共享

| No Comments | No TrackBacks
今天安装iDeneb 10.5.4发现这个小东西直接可以访问局域网内的其他mac机器,相当方便。
相对与apple remote desktop简单的多,没有那些高级功能也不错。

screenshare.png

简述:Watch Apple CEO Steve Jobs reveal what's new in Mac. 这个方法也适合其他Apple发布的视频. WWDC08 Keynote address就是我在WWDC会场下载的,那次很快,1G的网络.

apple_macbook_20081014.png

邊艾風

| 2 Comments | No TrackBacks
某友,最近身體不適.市場做惡夢.

某日,夢見一軍人,名曰"邊艾風"落難.
友冥思不得其解!

解夢:某友最近一直在編寫iphone App,那次夢的意識事,想變出一個iPhone供自己折騰.
        令一解釋:編(程)愛瘋,暗指自己喜歡愛瘋編程.

4 years my MacBooks

| 1 Comment | No TrackBacks
Thanks Mr. Wan & Duanmu
macbooksofyarshure.png


---yarshure kong的珍藏

Use 'po" print-object IN GDB

| No Comments | No TrackBacks

In the console, you have full access to all gdb's capabilities. One very handy feature is "print-object" ("po"). If a variable is a pointer to an object, it is sent the messagedescription when you "po" it, and the result is printed in the console. Try printing the newEntry variable.

po newEntry

setCalendarFormat 用法

| No Comments | No TrackBacks

- (void)setCalendarFormat:(NSString *)format


This method sets the default calendar format for the receiver. A calendar format is a string formatted with date-conversion specifiers, as given in Table 3.2.

Table 3.2. Possible Tokens in the Calendar Format String
SymbolMeaning
%yYear without century (00-99)
%YYear with century ("1990")
%bAbbreviated month name ("Jan")
%BFull month name ("January")
%mMonth as a decimal number (01-12)
%aAbbreviated weekday name ("Fri")
%AFull weekday name ("Friday")
%wWeekday as a decimal number (0-6), where Sunday is 0
%dDay of the month as a decimal number (01-31)
%eSame as %d but does not print the leading 0
%jDay of the year as a decimal number (001-366)
%HHour based on a 24-hour clock as a decimal number (00-23)
%IHour based on a 12-hour clock as a decimal number (01-12)
%pA.M./P.M. designation for the locale
%MMinute as a decimal number (00-59)
%SSecond as a decimal number (00-59)
%FMilliseconds as a decimal number (000-999)
%xDate using the date representation for the locale
%XTime using the time representation for the locale
%cShorthand for %X %x, the locale format for date and time
%ZTime zone name
%zTime zone offset in hours and minutes from GMT (HHMM)
%%% character