Recently in Apple 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
1 Dock Menu 效果如图
dock_menu.png
实现方法

NSApplicationDelegate

实现

- (NSMenu *)applicationDockMenu:(NSApplication *)sender

{

    return _menu;

}

2 状态条菜单

  需要NSMenuDelegate protocol

@protocol NSMenuDelegate <NSObject>

@optional

- (void)menuNeedsUpdate:(NSMenu*)menu;


- (NSInteger)numberOfItemsInMenu:(NSMenu*)menu;

- (BOOL)menu:(NSMenu*)menu updateItem:(NSMenuItem*)item atIndex:(NSInteger)index shouldCancel:(BOOL)shouldCancel;

- (void)menuWillOpen:(NSMenu *)menu;

- (void)menuDidClose:(NSMenu *)menu;

- (void)menu:(NSMenu *)menu willHighlightItem:(NSMenuItem *)item;

@end


statbar_menu.png

StatusBar加Icon

- (void)activateStatusMenu:(int)status

{

    NSStatusBar *bar = [NSStatusBar systemStatusBar];

    icon = [bar statusItemWithLength:NSVariableStatusItemLength];

    [icon retain];

NSString* filePath;

switch (status) {

case 0:

filePath = [[NSBundle mainBundle] pathForResource:@"sync_complete" ofType:@"png"];

break;

case 1:

filePath = [[NSBundle mainBundle] pathForResource:@"sync_processing" ofType:@"png"];

break;

case 2:

filePath = [[NSBundle mainBundle] pathForResource:@"sync_error" ofType:@"png"];

break;

default:

break;

}

NSImage* image = [[NSImage alloc] initWithContentsOfFile:filePath];

[icon setImage:image];

[icon setHighlightMode:YES];

[icon setMenu:mainMenu];

}


关于菜单就讲这么多

Steven P. Jobs 1955-2011

| No Comments | No TrackBacks


IMG_0002.jpg
苹果失去了一位富有远见和创造力的天才,世界失去了一位神人。我们这些有幸认识史蒂夫并与之公事的人们,失去了一位亲爱的朋友和激励我们的精神导师。史蒂夫留下了一个只有他才能开创的公司,他的精神将永远是苹果的基石。(苹果官网,孙方翻译)

PCM 音频格式播放

| No Comments | No TrackBacks
Mac 版本,理论上iOS 也没问题
使用CoreAudio Framework

pcmplayer.zip

WWDC归来

| No Comments | No TrackBacks
今年的WWDC 已经闭幕一个半月,回到上海已经一个月有于,总想写点什么,单不知从何写起。

WWDC 不只是技术会议,其实是技术人员的集会。如果你活跃在twitter和其他圈子,你可能会见到很多线上的朋友。这次我遇到了来自 加拿大独立开发者 @Anxonli ,来自国内上海的 独立开发者 @backspacer ,阿里系的开发者 @nowazhu ,来自AutoDesk的老朋友 @snakeeyxp。
还有很多朋友,如果不是因为WWDC,可能我们几乎没有见面的机会。

另外,WWDC期间我们认识第一财经周刊的记者,竟然不是哪的记者badge,而是以开发者身份参加,着实让我吃惊。
下面是这位记者的文章,估计很多人已经读过。

WWDC前期还遇到曾经给我回复过邮件的DTS Engineer。

原本打算在伯克利大学好好逛逛,无奈天公不做美,去的那天一直下雨。希望....

今年排队看乔布斯的人很多,下面是我拍摄的视频。

部分人还是买高价票去的,除了正常购买外,预留门票数量有限。

WWDC会议重要的不是session, 而是在Lab, 在Lab里面你可以拿你的代码去问苹果的工程师,一两句指点可能对你的产品有很大的帮助。

回来后同事和我聊天,说:"可以下载到Session视频,明年可以不用去了。" 也是许吧,毕竟整个行程费用不低。

写点攻略
1 旧金山的6月晚上还是毕竟凉,街上偶尔能看到穿棉衣的,如果去的时候没有准备,尽量还是买件厚点的衣服。
2 从机场到旧金山市区还是比较方便,如果没有出游计划不租车的话可以坐Burt
3 渔人码头39号Crab House Double shimp Double crab双虾双蟹 http://instagr.am/p/FawgA/
   一定要品尝,价格也不贵。
4 排队早晚去关系不是很大,攻略是进主会场后要蹲守在VIP区域附近。VIP区域可能是坐不满,机会很大,开场前会放一小部分观众过去。
5 会场提供早餐和午餐,基本一天都可以在会场里面。
6 如果购物,去Gilroy不错,在San Jose 南,沿着101开车即可到达。
7 斯坦福大学一定要去,今年看到很多系在搞毕业典礼。


先写这么多,照片拍了几十GB,还没有空整理,部分照片发到Flickr,地址 

Enhanced by Zemanta

美国签证

| No Comments | No TrackBacks
3年前去的美国参加WWDC08,今年签证流程和3年前变化很多
变化和比较:
1 表格都是电子的啦,原来需要网上填写DS-158,填写电子版DS-157。目前只需要填写DS-160,填好后打印确认页即可。
2 到中信银行支付签证费,其中包含收据编号,这个后面要用。接下来购买电话卡,电话预约,需要提交签证费收据编号/护照号等信息。确定面试时间。
   08年的时候预约是不需要签证费收据编号,因为这个事情我面试晚了三天。
3 面试当天最好早点起床/出发,我今天早上到梅龙镇广场已经7点半,前面排了很多人。后面跟着大家走就好,拿号牌,上楼,交号牌,过安检,提交(护照/付款收据/EMS回传单/DS160确认页),换取黄色号码牌,扫描指纹,面试。整个流程持续有差3个小时,感觉一致都是在排队。
4 面试很简单,说明目的,签证官看看护照/邀请函就pass了。
5 这次签证回传没有选择去巨鹿路邮局领取,08年那次自己取的,回传费08年是先支付,目前是收到后支付。-- 护照回传

yarshure
2011-5-6 上海


Open Path Use Finder

| No Comments | No TrackBacks

Code 1 use NSTask:

NSTask *openr = [[NSTask alloc] init]; 

[openr setLaunchPath:@"/usr/bin/open"]; 

[openr setArguments:[NSArray arrayWithObject:@"/Users/yarshure/Pictures/"]];

[openr launch]; 

[openr autorelease];

Code 2 use NSWorkspace:


[[NSWorkspace sharedWorkspace] openFile:@"/Users/yarshure/Pictures/" withApplication:@"Finder"];

Enhanced by Zemanta
介绍
Advanced iPhone Development - Fall 2010

While there are many resources out there to help you get started in developing for iPhone OS devices, this course aims to answer the question: "What next?"  Fundamentals of Cocoa development are explained, but the class quickly moves on to coverage of the many interesting frameworks within iPhone OS.  Topics such as Core Animation, Core Data, OpenGL ES, multithreading, and iPad-specific development are presented from the perspective of an experienced Cocoa developer.


This course is offered by the Madison Area Technical College's Information Technology Department and is a once-a-week professional development class.  Course videos are made available in 720p HD upon the completion of the semester, and the detailed course notes (in VoodooPad format) can also be downloaded from the iTunes U class page.  Links to all sample applications used for the course can be found in the notes.


Prerequisites: Completion of iPhone Apps Development or previous experience with developing for the iPhone OS platform.
Dr. Brad Larson 主讲
屏幕快照 2010-11-29 下午01.04.40.png的缩略图

课程内容
1. Introduction : Design of iOS applications.mp4
2. Understanding Cocoa : Targeting multiple OS versions and devices.mp4
3. Testing.mp4
4. Views and view controllers.mp4
5. Quartz 2D.mp4
6. Core Animation.mp4
7. Core Data.mp4
8. Touches, scroll views, and the accelerometer.mp4
9. Networking.mp4
10. Camera, audio, and video.mp4
11. Performance tuning.mp4
12. Multithreading, multitasking, and GCD.mp4
13.OpenGL ES 20.mp4


打算学习AppleScript, Oreilly正好有本中文的书(《AppleScript权威指南(第二版)》)

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





Safari4 Beta

| No Comments | No TrackBacks
safari4beat.JPG