Recently in Coding Category




截图就不更新了,体验的赶紧下载尝鲜吧。

AirPlay.png
AirPlay.zip  下载链接,点击前面的那个
1 支持专辑和Artist 图片效果
2 目前只用pre, pause,n 操作
3 显示当前播的音乐专辑,演唱者,歌曲名字
4 目前不支持切换电台,下周会实现
   可以手动切电台http://restful.airplayme.com/radios/selected.json 查看电台id
   然后手动替换 defaultstation.plist 文件中id 项目,重启即可

2011.12.06 晚上版本
preview.png
下载地址:


1 界面美化
2 简单指出选电台
2011.12.07 更新
1 优化版本 胶片效果完善
2 修改启动时不显示界面问题

channel.png


早期功能版本
1 频道选择
2 歌曲/艺人/专辑搜索
3 歌词显示
4 seek 功能

airplay_func_ver.png



Enhanced by Zemanta

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

昨天写的script

| No Comments | No TrackBacks

#!/bin/sh

apppath=`xcodebuild |grep Validation|awk '{print $2}'`

sign='iPhone Distribution:Yarshure Kong Healthcare Communications Co., Ltd.'

ipapath=`pwd`'/BlanceBall.ipa'

echo $apppath

/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/PackageApplication  -s "$sign" "$apppath" -o "$ipapath"

scp "$ipapath" macgeeks:~/macgeeks.cn/bbs/apps/


Enhanced by Zemanta

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
介绍
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


iOS 4.2 中下面3个方法iOS 3.2 不存在

[NSFileManager URLsForDirectory:inDomains:]
[NSBundle URLForResource:withExtension:]
前两个是CoreData 用到

下面的这个是UIView block 动画,iOS 3.2 也是不支持地
[UIView animateWithDuration:animations:completion:]


期待iOS 4.2 早点放JB吧,就可以放弃3.2了

ObjC ICU 正则

| No Comments | No TrackBacks

-(NSString*)removeHTMLTag:(NSString*)src

{

NSError *error = NULL;

NSMutableString *dest=[NSMutableString stringWithCapacity:0];

NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"<a href=\".+?\">(.+?)</a>"

  options:NSRegularExpressionCaseInsensitive

error:&error];

NSRegularExpression* regex2 = [[NSRegularExpression alloc] initWithPattern:@"(?<=>).*?(?=</a>)" options:NSRegularExpressionCaseInsensitive error:nil];

NSUInteger numberOfMatches = [regex numberOfMatchesInString:src

options:0

  range:NSMakeRange(0, [src length])];


if (numberOfMatches !=0) {

[dest appendString:src];

[regex enumerateMatchesInString:src options:0 range:NSMakeRange(0, [src length]) 

usingBlock:^(NSTextCheckingResult *result, NSMatchingFlags flags, BOOL *stop) {

 

 

NSString*resultString = [src substringWithRange:[result range]];

NSString*link=[resultString substringWithRange:[[regex2 firstMatchInString:resultString options:0 range:NSMakeRange(0,[resultString length])] range]];

 

[dest replaceCharactersInRange:[result range] withString:link];

}];

return [dest stringByReplacingOccurrencesOfString:@"<br />" withString:@""];

} else {

return [src stringByReplacingOccurrencesOfString:@"<br />" withString:@""];

}

}

lldb help

| No Comments | No TrackBacks
MacBook-Pro:~ yarshure$ /Users/yarshure/lldb/lldb/build/Debug/lldb 
(lldb) help
The following is a list of built-in, permanent debugger commands:

alias        -- Allows users to define their own debugger command abbreviations.
append       -- Allows the user to append a value to a single debugger setting variable, for settings that are of list types. Type 'settings' to see a list of debugger setting variables
apropos      -- Finds a list of debugger commands related to a particular word/subject.
breakpoint   -- A set of commands for operating on breakpoints.
call         -- Call a function.
delete       -- Lists the kinds of objects you can delete, and shows syntax for deleting them.
disassemble  -- Disassemble bytes in the current function or anywhere in the inferior program.
expression   -- Evaluate a C expression in the current program context, using variables currently in scope.
file         -- Sets the file to be used as the main executable by the debugger.
frame        -- A set of commands for operating on the current thread's frames.
help         -- Shows a list of all debugger commands, or give details about specific commands.
image        -- Access information for one or more executable images.
info         -- Lists the kinds of objects for which you can get information, and shows the syntax for doing so.
log          -- A set of commands for operating on logs.
memory       -- A set of commands for operating on a memory.
process      -- A set of commands for operating on a process.
quit         -- Quits out of the LLDB debugger.
regexp-break -- Smart breakpoint command (using regular expressions).
register     -- Access thread registers.
script       -- Passes an expression to the script interpreter for evaluation and returns the results. Drops user into the interactive interpreter if no expressions are given.
select       -- Lists the kinds of objects you can select, and shows syntax for selecting them.
set          -- Allows the user to set or change the value of a single debugger setting variable.
settings     -- Lists the debugger settings variables available to the user to 'set' or 'show'.
show         -- Allows the user to see a single debugger setting variable and its value, or lists them all.
source       -- Reads in debugger commands from the file <filename> and executes them.
source-file  -- Display source files from the current executable's debug info.
target       -- A set of commands for operating on debugger targets.
thread       -- A set of commands for operating on one or more thread within a running process.
unalias      -- Allows the user to remove/delete a user-defined command abbreviation.
variable     -- Access program arguments, locals, static and global variables.

The following is a list of your current command abbreviations (see 'alias' for more info):

bt       -- ('thread backtrace')  Shows the stack for one or more threads.
c        -- ('process continue')  Continues execution all threads in the current process.
continue -- ('process continue')  Continues execution all threads in the current process.
exit     -- ('quit')  Quits out of the LLDB debugger.
expr     -- ('expression')  Evaluate a C expression in the current program context, using variables currently in scope.
finish   -- ('thread step-out')  Source level single step out in specified thread (current thread, if none specified).
l        -- ('source-file')  Display source files from the current executable's debug info.
list     -- ('source-file')  Display source files from the current executable's debug info.
n        -- ('thread step-over')  Source level single step over in specified thread (current thread, if none specified).
next     -- ('thread step-over')  Source level single step over in specified thread (current thread, if none specified).
q        -- ('quit')  Quits out of the LLDB debugger.
r        -- ('process launch')  Launches the executable in the debugger.
run      -- ('process launch')  Launches the executable in the debugger.
s        -- ('thread step-in')  Source level single step in in specified thread (current thread, if none specified).
si       -- ('thread step-inst')  Single step one instruction in specified thread (current thread, if none specified).
step     -- ('thread step-in')  Source level single step in in specified thread (current thread, if none specified).
x        -- ('memory read')  Read memory from the process being debugged.

For more information on any particular command, try 'help <command-name>'.
Enhanced by Zemanta

NSOperation and KVO/KVC coding

| No Comments | No TrackBacks

本文简要介绍如何使用KVO 跟踪NSOperation 状态


traceOperation 方法跟踪 PageLoadOperation(NSOperation 子类)

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    

    

    // Override point for customization after app launch 

for (NSString *urlString in urlArray

{

        NSURL *url = [NSURL URLWithString:urlString];

        PageLoadOperation *plo = [[PageLoadOperation alloc] initWithURL:url];

        [queue addOperation:plo];

[self traceOperation:plo];

        [plo release];

    }

    [window addSubview:viewController.view];

    [window makeKeyAndVisible];

return YES;

}

traceOperation 方法

KeyPath 官方文档说明 http://developer.apple.com/mac/library/documentation/cocoa/reference/NSOperation_class/Reference/Reference.html#//apple_ref/doc/c_ref/NSOperation

KVO-Compliant Properties

The NSOperation class is key-value coding (KVC) and key-value observing (KVO) compliant for several of its properties. As needed, you can observe these properties to control other parts of your application. The properties you can observe include the following:

  • isCancelled - read-only property

  • isConcurrent - read-only property

  • isExecuting - read-only property

  • isFinished - read-only property

  • isReady - read-only property

  • dependencies - read-only property

  • queuePriority - readable and writable property

  • completionBlock - readable and writable property (Mac OS X only)

-(void)traceOperation:(NSOperation*)obj

{

[obj addObserver:self

  forKeyPath:@"isExecuting"

  options:0

  context:NULL];

[obj addObserver:self

  forKeyPath:@"isFinished"

  options:0

  context:NULL];

[obj addObserver:self

  forKeyPath:@"isReady"

options:0

context:NULL];

[obj addObserver:self

  forKeyPath:@"isCancelled"

options:0

context:NULL];

}


Quartz 2D 基础

| No Comments | No TrackBacks
CGImageCreateWithImageInRect 使用

如何画矩形

CGRect backRect = CGRectMake(1010508);

CGContextSetRGBFillColor(context, 1.01.01.01.0);

CGContextFillRect(context, backRect);


下面的代码是选择坐标系

CGContextTranslateCTM(context, 0.0self.frame.size.height);

CGContextScaleCTM(context, 1.0, -1.0);

CGContextShowTextAtPoint 不能draw中文,中文等UTF8 需要用

NSString drawAtPoint 这个方法

看看效果
屏幕快照 2009-12-09 上午02.48.31.png