<?xml version="1.0" encoding="UTF-8"?> <rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
> <channel><title>以太之内 生存之上 &#187; Coding</title> <atom:link href="http://ixhan.com/category/coding/feed/" rel="self" type="application/rss+xml" /><link>http://ixhan.com</link> <description>Live in your world, get owned in mine</description> <lastBuildDate>Tue, 15 May 2012 04:08:15 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.2</generator> <item><title>JSONKit :Illegal \u Unicode escape sequence</title><link>http://ixhan.com/2012/04/jsonkit-illegal-unicode-escape-sequenc/</link> <comments>http://ixhan.com/2012/04/jsonkit-illegal-unicode-escape-sequenc/#comments</comments> <pubDate>Fri, 27 Apr 2012 08:27:30 +0000</pubDate> <dc:creator>xhan</dc:creator> <category><![CDATA[Coding]]></category> <category><![CDATA[JSONKit]]></category> <guid
isPermaLink="false">http://ixhan.com/?p=790</guid> <description><![CDATA[<a
href="http://ixhan.com/2012/04/jsonkit-illegal-unicode-escape-sequenc/" title="JSONKit :Illegal \u Unicode escape sequence"></a>When JSON string contains unicodes between u0000 and u001f, JSONKit parser fails to work properly. and throws a error as &#8220;Illegal \u Unicode escape sequence&#8221;. This is a known issue(link) but seems like the author thought it&#8217;s a fault caused &#8230;<p
class="read-more"><a
href="http://ixhan.com/2012/04/jsonkit-illegal-unicode-escape-sequenc/">Read more &#187;</a></p>]]></description> <content:encoded><![CDATA[<a
href="http://ixhan.com/2012/04/jsonkit-illegal-unicode-escape-sequenc/" title="JSONKit :Illegal \u Unicode escape sequence"></a><p>When JSON string contains unicodes between u0000 and u001f, JSONKit parser fails to work properly. and throws a error as &#8220;Illegal \u Unicode escape sequence&#8221;.</p><p>This is a known issue(<a
target="_blank" href="https://github.com/johnezang/JSONKit/pull/26">link</a>) but seems like the author thought it&#8217;s a fault caused by content provider and didn&#8217;t intend to have any fix on this issue.</p><blockquote><p>In this particular case, these services are very clearly &#8220;in the wrong&#8221;. <a
target="_blank" href="http://tools.ietf.org/html/rfc4627">RFC 4627</a> is unambiguous that characters &lt; <code>0x20</code>are verboten. In cases like there, where something is clearly violating the standard, my default response is that &#8220;It&#8217;s the other persons (web service) problem.&#8221; The standard is the standard, and it is Right(tm), even its mistakes.</p></blockquote><p>But in fact there are many JSON encoder may generates JSON string contains invalid characters &lt; 0&#215;20 including Python2.6, &lt;not tested in Python2.7&gt;, pre-rails3. We all love the clean codes but we need make things done first.</p><p><strong>SOLUTION:</strong></p><p>Edit JSONKit.m file:</p><pre> //GOTO Line 1462 or nearby
//      remove this line
//      if(JK_EXPECT_F(currentChar &lt; 0x20UL)) { jk_error(parseState, @"Invalid character &lt; 0x20 found in string: 0x%2.2x.", currentChar); stringState = JSONStringStateError; goto finishedParsing; }
//      add following codes
        if(JK_EXPECT_F(currentChar &lt; 0x20UL) &amp;&amp; (parseState-&gt;parseOptionFlags &amp; JKParseOptionLooseUnicode) == 0) {
            jk_error(parseState, @"Invalid character &lt; 0x20 found in string: 0x%2.2x.", currentChar); stringState = JSONStringStateError; goto finishedParsing;
        }
        else {
            currentChar = 0xFFFDUL;
        }</pre><h3  class="related_post_title">Random Posts</h3><ul
class="related_post"><li><a
href="http://ixhan.com/2009/12/2009-2010/" title="2009-2010 ">2009-2010 </a></li><li><a
href="http://ixhan.com/2009/11/osx-terminal-keyshort/" title="OSX Terminal(终端) 使用快捷键">OSX Terminal(终端) 使用快捷键</a></li><li><a
href="http://ixhan.com/2010/10/10-7/" title="10.7">10.7</a></li><li><a
href="http://ixhan.com/2010/07/prepare-for-battle/" title="Prepare For Battle">Prepare For Battle</a></li></ul>]]></content:encoded> <wfw:commentRss>http://ixhan.com/2012/04/jsonkit-illegal-unicode-escape-sequenc/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Apple LLVM 4.0 带给ObjC的新语法</title><link>http://ixhan.com/2012/02/apple-llvm-4-0-new-features-on-objectivec/</link> <comments>http://ixhan.com/2012/02/apple-llvm-4-0-new-features-on-objectivec/#comments</comments> <pubDate>Mon, 20 Feb 2012 06:34:17 +0000</pubDate> <dc:creator>xhan</dc:creator> <category><![CDATA[奇巧淫技]]></category> <category><![CDATA[Coding]]></category> <category><![CDATA[llvm4.0]]></category> <category><![CDATA[objc]]></category> <category><![CDATA[objectivec]]></category> <category><![CDATA[xcode4.4]]></category> <guid
isPermaLink="false">http://ixhan.com/?p=751</guid> <description><![CDATA[<a
href="http://ixhan.com/2012/02/apple-llvm-4-0-new-features-on-objectivec/" title="Apple LLVM 4.0 带给ObjC的新语法"></a>下载了Xcode4.4 Preview版本, 里面有段介绍: Xcode now includes the Apple LLVM Compiler version 4.0, including the following newObjective-C language features: Default @synthesize: automatically synthesizes an @property when unimplemented Objective-C literals: create literals for NSArray, NSDictionary, and NSNumber, just the same as the &#8230;<p
class="read-more"><a
href="http://ixhan.com/2012/02/apple-llvm-4-0-new-features-on-objectivec/">Read more &#187;</a></p>]]></description> <content:encoded><![CDATA[<a
href="http://ixhan.com/2012/02/apple-llvm-4-0-new-features-on-objectivec/" title="Apple LLVM 4.0 带给ObjC的新语法"></a><p>下载了Xcode4.4 Preview版本, 里面有段介绍:</p><blockquote><p>Xcode now includes the Apple LLVM Compiler version 4.0, including the following newObjective-C language features:</p><ul><li>Default @synthesize: automatically synthesizes an @property when unimplemented</li><li>Objective-C literals: create literals for NSArray, NSDictionary, and NSNumber, just the same as the literals for NSString</li><li>Objective-C container subscripting: use &#8216;[]&#8216; syntax to access containers such asNSArray and NSDictionary</li></ul></blockquote><p>一和三很好理解, 第二条没看懂. 搜索了下立马爽歪了. 这几个新特性真可以加快不少开发速度!</p><h2>Objective-C literals</h2><p><strong>NSArray Literals</strong></p><p><em>Previously:</em></p><pre>array = [NSArray arrayWithObjects:a, b, c, nil];</pre><p><em>Now:</em></p><pre>array = @[ a, b, c ];</pre><p><strong>NSDictionary Literals</strong></p><p><em>Previously:</em></p><pre>dict = [NSDictionary dictionaryWithObjects:@[o1, o2, o3]
					forKeys:@[k1, k2, k3]];</pre><p><em>Now:</em></p><pre>dict = @{ k1 : o1, k2 : o2, k3 : o3 };</pre><p><strong>NSNumber Literals</strong></p><p><em>Previously:</em></p><pre>NSNumber *number;
number = [NSNumber numberWithChar:'X'];
number = [NSNumber numberWithInt:12345];
number = [NSNumber numberWithUnsignedLong:12345ul];
number = [NSNumber numberWithLongLong:12345ll];
number = [NSNumber numberWithFloat:123.45f];
number = [NSNumber numberWithDouble:123.45];
number = [NSNumber numberWithBool:YES];</pre><p><em>Now:</em></p><pre>NSNumber *number;
number = @'X';
number = @12345;
number = @12345ul;
number = @12345ll;
number = @123.45f;
number = @123.45;
number = @YES;</pre><p><a
target="_blank" href="http://cocoaheads.tumblr.com/post/17757846453/objective-c-literals-for-nsdictionary-nsarray-and" target="_blank">原文Link</a></p><h3  class="related_post_title">Random Posts</h3><ul
class="related_post"><li><a
href="http://ixhan.com/2009/11/drawing/" title="涂鸦">涂鸦</a></li><li><a
href="http://ixhan.com/2009/10/redmine-images-manager-system/" title="用 Redmine 管理iPhone项目中过多的图片文件">用 Redmine 管理iPhone项目中过多的图片文件</a></li><li><a
href="http://ixhan.com/2010/03/tutorial-of-kissxml-iphone/" title="Tutorial of  kissXML(iPhone)">Tutorial of  kissXML(iPhone)</a></li><li><a
href="http://ixhan.com/2011/09/uitableview-offset-to-top-unexpected/" title="UITableView 离奇滚动到顶部的问题">UITableView 离奇滚动到顶部的问题</a></li></ul>]]></content:encoded> <wfw:commentRss>http://ixhan.com/2012/02/apple-llvm-4-0-new-features-on-objectivec/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> <item><title>OSX下自定义文件类型和QuickLook</title><link>http://ixhan.com/2012/02/define-custom-file-format-on-osx/</link> <comments>http://ixhan.com/2012/02/define-custom-file-format-on-osx/#comments</comments> <pubDate>Sat, 18 Feb 2012 12:20:37 +0000</pubDate> <dc:creator>xhan</dc:creator> <category><![CDATA[Coding]]></category> <category><![CDATA[Knowledge]]></category> <category><![CDATA[Cocoa]]></category> <category><![CDATA[osx]]></category> <category><![CDATA[QuickLook]]></category> <category><![CDATA[xcode]]></category> <guid
isPermaLink="false">http://ixhan.com/?p=743</guid> <description><![CDATA[<a
href="http://ixhan.com/2012/02/define-custom-file-format-on-osx/" title="OSX下自定义文件类型和QuickLook"></a>研究了几个小时如何自定义文件类型和自定义的QuickLook, 怕以后忘记怎么操作了. 总结下流程和写下简单的教程. 如果 你想让你的程序支持自定义的文件类型 让自定义的文件支持苹果的 Quick Look (大致就是选中文件按下空格后的预览图) 请继续看 &#8211;&#62; 测试的例子是 Single Window Application + Custom bundle file type 不只是文档程序,单窗口程序也能支持响应自定义的文件类型 Bundle 简单的说就是个文件夹, OSX系统可以将bundle识别单独的文件: 比如你的app就是个bundle. bundle在OSX下有许多作用,甚至还能对现有的app提供插件支持. 我们的目标是让 &#60;name&#62;.xxx 文件夹(里面有个叫xxx.jpg的图片) 被识别成bundle 有个独立的图标 能被 app 打开并在窗口显示 xxx.jpg 能提供Preview并显示 xxx.jpg 马上开始,为了节约时间略了些细节和图片描述, 请自行补充,无需100%按部就班 Part &#8230;<p
class="read-more"><a
href="http://ixhan.com/2012/02/define-custom-file-format-on-osx/">Read more &#187;</a></p>]]></description> <content:encoded><![CDATA[<a
href="http://ixhan.com/2012/02/define-custom-file-format-on-osx/" title="OSX下自定义文件类型和QuickLook"></a><p>研究了几个小时如何自定义文件类型和自定义的QuickLook, 怕以后忘记怎么操作了. 总结下流程和写下简单的教程.</p><div
style="font-size: 300%;">如果</div><div
style="font-size: 300%;"></div><ul><li>你想让你的程序支持自定义的文件类型</li><li>让自定义的文件支持苹果的 Quick Look (大致就是选中文件按下空格后的预览图)</li></ul><div>请继续看 &#8211;&gt;</div><div></div><div>测试的例子是 Single Window Application + Custom bundle file type</div><div></div><ol><li>不只是文档程序,单窗口程序也能支持响应自定义的文件类型</li><li>Bundle 简单的说就是个文件夹, OSX系统可以将bundle识别单独的文件: 比如你的app就是个bundle. bundle在OSX下有许多作用,甚至还能对现有的app提供插件支持.</li></ol><div>我们的目标是让 &lt;name&gt;.xxx 文件夹(里面有个叫xxx.jpg的图片)</div><ul><li>被识别成bundle</li><li>有个独立的图标</li><li>能被 app 打开并在窗口显示 xxx.jpg</li><li>能提供Preview并显示 xxx.jpg</li></ul><blockquote><div>马上开始,为了节约时间略了些细节和图片描述, 请自行补充,无需100%按部就班</div></blockquote><h3>Part I</h3><p><strong>创建自定义文件:</strong>  新建个 name.xxx 的文件夹并丢入一照片命名为 xxx.jpg</p><p><strong>Xcode中新建一个App:</strong> 在MainMenu里的view中拖入一个ImageView 并绑定到 AppDelegate 的imageView属性.</p><p><strong>给App加个ICON:</strong> 拖入图标后,在info.plist里的图标选项里补充上名字</p><p><strong>App注册自定义文件: </strong>在info.plist 里添加新字段 UTExportedTypeDeclarations (自动补全后应该是array内容) 编辑内容如下:<br
/> <a
href="http://ixhan.com/wp-content/uploads/2012/02/Exported-Type-UTIs.png"><img
class="size-full wp-image-745" title="Exported Type UTIs" src="http://ixhan.com/wp-content/uploads/2012/02/Exported-Type-UTIs.png" alt="" width="635" height="207" /></a><br
/> UTTypeConformsTo 是指我们自定义文件的类型,  identifier和filename-extension是至次自定义文件的标识和后缀.</p><p><strong>App注册文档文件: </strong>只有注册指定的UTI(上步骤)为documentType, 才能使用此App打开该类型的文件. plist里添加新key,如图操作<br
/> <a
href="http://ixhan.com/wp-content/uploads/2012/02/Document-types.png"><img
class="size-full wp-image-744" title="Document types" src="http://ixhan.com/wp-content/uploads/2012/02/Document-types.png" alt="" width="637" height="205" /></a></p><p>每个key内容就不解释了,自己查阅文档 <img
src='http://ixhan.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /></p><p>编译运行App,然后关闭.  你应该可以看到 name.xxx 文件夹已经显示为一个带着你指定图标的文件了. 当然还是可以通过点右键-&gt; Show Package Contents 来查看包内的内容.</p><h3>Part II</h3><p>目前双击 name.xxx 已可以成功打开我们的App, 但是有个&#8221;无法打开***&#8221;的错误提示.</p><p><strong>添加app文件打开处理:</strong> 在AppDelegate.m 里添加如下代码</p><pre>- (BOOL)application:(NSApplication *)sender openFile:(NSString *)filename
{
    NSString*path = [filename stringByAppendingPathComponent:@"xxx.jpg"];
    NSImage* img = [[NSImage alloc] initWithContentsOfFile:path];
    if (img) {
        _imageview.image = img;
        return YES;
    }else{
        return NO;
    }
}</pre><p>现在已经可以成功处理打开自定义文件了 Wowowow! (测试中有个问题,返回NO也没出现 出错提示, 看来需要自己判断文件有效性 并弹出错误提示了 )  ,接下来就是非常好玩的 Quick Look 了!!!</p><h3>Part III</h3><p>选中 name.xxx , 按下空格后出现的放大的图标. 看起来还不错? NO, 必须得能够显示包内的图片才够完美啊.</p><blockquote><p>PS. 其实让Package 文件支持Preview是非常容易的, 在包内新建 QuickLook 文件夹, 并放入 Preview.jpg 即可. 不过此方法不够灵活,  我就蛋疼的演示下写个自己的 Quick Look 插件.</p></blockquote><p>Quick Look 插件是后缀为 .qlgenerator 的bundle, 有3处地方可以放置此插件</p><ul><li>/Library/QuickLook       &lt;系统级别的,安装iWork后里面就有个给iWork文档提供preview的插件&gt;</li><li>~/Library/QuickLook       &lt;用户级别的&gt;</li><li>&lt;name&gt;.app/content/Library/QuickLook   &lt;App级别的&gt;</li></ul><div>我们这里选择方案3 &lt;App级别&gt; 开始:</div><div></div><div><strong>App 工程新建Target:</strong> 选择 System PlugIns / QuickLook Plug-In</div><div>目录中生成了3个文件, 根据提示咱们不要改动main.c 文件, 将其他两个.c文件修改为.m , 由于对于CoreFoundation的函数实在没好感, 修改为.m 后方便继续使用高级别的API进行操作.</div><div></div><div><strong>给此Target添加framework:</strong> cocoa.framework  (选中项目,右边的target, build parses / Linked With Libraries 里添加)</div><div></div><div>修改 GeneratePreviewForURL.m 里的同名方法如下 :</div><pre>OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview, CFURLRef url, CFStringRef contentTypeUTI, CFDictionaryRef options)
{
    NSAutoreleasePool *pool;
    pool = [[NSAutoreleasePool alloc] init];
    NSURL*imgurl = [(NSURL*)url URLByAppendingPathComponent:@"oo.jpg"];
    NSLog(@"!xxx get path %@",imgurl);
    NSImage* img = [[NSImage alloc] initWithContentsOfURL:imgurl];
    if (img) {
        NSSize size = img.size;
        CGContextRef cgContext = QLPreviewRequestCreateContext(preview, *(CGSize *)&amp;size, true, NULL);
        if (cgContext) {
            NSGraphicsContext* context = [NSGraphicsContext graphicsContextWithGraphicsPort:(void *)cgContext flipped:YES];
            if (context) {
                [NSGraphicsContext saveGraphicsState];
                [NSGraphicsContext setCurrentContext:context];
                [img drawAtPoint:NSMakePoint(0, 0)
                        fromRect:NSMakeRect(0, 0, 0, 0)
                       operation:NSCompositeCopy
                        fraction:1];
                [NSGraphicsContext restoreGraphicsState];
                QLPreviewRequestFlushContext(preview, cgContext);
                CFRelease(cgContext);
            }
        }
        [img release];
    }
    [pool release];
    return noErr;
}</pre><p>贴的代码有点多, 简单说下步骤</p><ul><li>根据传过来的url 生成 NSImage</li><li>获取到 Preview的上下文, 并转换成 NS* 的上下文</li><li>将图片绘制进当前的上下文</li><li>然后刷新 Preview 显示内容</li></ul><div><span
class="Apple-style-span" style="line-height: 18px;"><strong>注意2点</strong>: 由于使用了foundation, 所以需要加入Autorelease pool.  由于plugin不好调试, 可以使用NSLog打入消息, 然后在 console 里 filter 来查看状况. </span></div><div></div><div><span
class="Apple-style-span" style="line-height: 18px;">最后一步, 回到App的项目设置里, 新建一个 copy 的 Build Phases, 设置如下 : </span></div><div><a
href="http://ixhan.com/wp-content/uploads/2012/02/copy-build-phase.png"><img
class="alignnone size-full wp-image-746" title="copy build phase" src="http://ixhan.com/wp-content/uploads/2012/02/copy-build-phase.png" alt="" width="506" height="193" /></a></div><p>再次编译运行App后, 测试下是否成功!!!!!</p><div
style="font-size: 300%;">DONE</div><h3  class="related_post_title">Related Posts</h3><ul
class="related_post"><li><a
href="http://ixhan.com/lesslyrics/" title="LessLyrics">LessLyrics</a></li></ul>]]></content:encoded> <wfw:commentRss>http://ixhan.com/2012/02/define-custom-file-format-on-osx/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>ObjC中URL编码</title><link>http://ixhan.com/2011/09/objective-c-url-encoding/</link> <comments>http://ixhan.com/2011/09/objective-c-url-encoding/#comments</comments> <pubDate>Thu, 29 Sep 2011 10:30:00 +0000</pubDate> <dc:creator>xhan</dc:creator> <category><![CDATA[Coding]]></category> <category><![CDATA[NSString]]></category> <category><![CDATA[URL encoding]]></category> <guid
isPermaLink="false">http://ixhan.com/?p=638</guid> <description><![CDATA[<a
href="http://ixhan.com/2011/09/objective-c-url-encoding/" title="ObjC中URL编码"></a>NSString类已经中提供了现成的API： 但是非常重要的一点苹果没注明：该API并不会将&#8221;&#38; + -&#8221;等需要转义的字符编码。 如若将需要传递的某个param的内容通过该API来转义就可能坑爹了！！你内容中的&#38;=不会被转义，服务端就会把原来的内容根据&#38;和=拆开成一片一片了！！ 解决方法是使用介绍中提到的CFURLCreateStringByAddingPercentEscapes 需要注意的是不能将这个函数用来 encode 整个URL，而是params的内容 &#8212; 写这篇文章是因为自己也掉了这个大坑，而且半年后才注意到。惨吖，不知道收集的10多w条数据中有多少是内容破坏的 &#8211; - Related PostsRead UTF8 code at specify position from an NSString]]></description> <content:encoded><![CDATA[<a
href="http://ixhan.com/2011/09/objective-c-url-encoding/" title="ObjC中URL编码"></a><p>NSString类已经中提供了现成的API：</p><pre class="brush: objc; title: ; notranslate">
/* Adds all percent escapes necessary to convert the receiver in to a legal URL string.
  Uses the given encoding to determine the correct percent escapes (returning nil if
the given encoding cannot encode a particular character).  See
CFURLCreateStringByAddingPercentEscapes in CFURL.h for more complex transformations
*/
- (NSString *)stringByAddingPercentEscapesUsingEncoding:(NSStringEncoding)enc;
</pre><p>但是非常重要的一点苹果没注明：该API并不会将&#8221;&amp; + -&#8221;等需要转义的字符编码。<br
/> 如若将需要传递的某个param的内容通过该API来转义就可能坑爹了！！你内容中的&amp;=不会被转义，服务端就会把原来的内容根据&amp;和=拆开成一片一片了！！</p><p>解决方法是使用介绍中提到的CFURLCreateStringByAddingPercentEscapes</p><pre class="brush: objc; title: ; notranslate">
@implementation NSString (URLEscaped)
- (NSString *)URLEscaped {
	CFStringRef escaped = CFURLCreateStringByAddingPercentEscapes(NULL, (CFStringRef)self, NULL, (CFStringRef)@&quot;!*'();:@&amp;=+$,/?%#[]&quot;,
			 kCFStringEncodingUTF8);
	NSString *out = [NSString stringWithString:(NSString *)escaped];
	CFRelease(escaped);
	return [[out copy] autorelease];
}
</pre><p>需要注意的是不能将这个函数用来 encode 整个URL，而是params的内容</p><p>&#8212;<br
/> 写这篇文章是因为自己也掉了这个大坑，而且半年后才注意到。惨吖，不知道收集的10多w条数据中有多少是内容破坏的 &#8211; -</p><h3  class="related_post_title">Related Posts</h3><ul
class="related_post"><li><a
href="http://ixhan.com/2011/02/read-utf8-code-at-specify-position-from-an-nsstring/" title="Read UTF8 code at specify position from an NSString">Read UTF8 code at specify position from an NSString</a></li></ul>]]></content:encoded> <wfw:commentRss>http://ixhan.com/2011/09/objective-c-url-encoding/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>LessLyrics 重启</title><link>http://ixhan.com/2011/09/lesslyrics-relaunch-now/</link> <comments>http://ixhan.com/2011/09/lesslyrics-relaunch-now/#comments</comments> <pubDate>Wed, 21 Sep 2011 15:00:03 +0000</pubDate> <dc:creator>xhan</dc:creator> <category><![CDATA[Coding]]></category> <category><![CDATA[Project]]></category> <category><![CDATA[LessLyrics]]></category> <guid
isPermaLink="false">http://ixhan.com/?p=621</guid> <description><![CDATA[<a
href="http://ixhan.com/2011/09/lesslyrics-relaunch-now/" title="LessLyrics 重启"></a>原谅4月份时候的大放厥词 &#8220;LessLyrics歌词秀后续计划&#8221; 今天写这文章时才发现居然又过去了5个月。这几个月里辞去了百度的工作，和朋友们开始了全新的创业之路，断断续续的也就选择性的忘记了这个升级计划。 当然还有2个原因，计划的0.8版本中无缝滚动动画效果依赖非常精确的iTunes播放时间，但是能取到最小的间隔是1秒，所以处理起一些细节会比较麻烦。但是呢从当时的预览视频可以看到其实当时完成度已经很高了，在我开心的向datou炫耀这个超级华丽无缝歌词滚动动画效果，结果datou研究了很久后，说了句。不好。 虽然不愿意承认这么帅气的效果被否决，但仔细想确实有很大的问题。无缝滚动效果会导致整个界面一直处于动画中，当前高亮播放中的歌词也一直在逐渐向上滚动，会导致使用者为了fo这行歌词一直让眼球向上扫描，接着目光聚集到下面的歌词，然后又继续向上扫。看久了就会觉得挺累。 昨天在我们的app内测qq群中有用户问要显示歌词的软件。我赶紧推荐了LessLyrics，结果人家居然说，居然说，说：“这个app早就知道了！！我想要iPhone版本的” 于是我爽到现在，于是决定必须立刻重新启动LessLyrics软件计划了！ 新的0.8版本没增加太多的功能，因为迫不及待要发布新版本收集下反馈。这次完全重写了app的设计结构和渲染模块（现在看1年前刚学习mac开发的代码真的很戳），接下来的添加新功能就方便了。 不用期待，几小时内发布。 哈哈哈哈哈哈哈哈哈哈哈哈哈哈。 下载请移步至 项目页面 Related PostsLyrics TutorialLessDJLessLyrics 歌词秀后续计划LessLyrics]]></description> <content:encoded><![CDATA[<a
href="http://ixhan.com/2011/09/lesslyrics-relaunch-now/" title="LessLyrics 重启"></a><p>原谅4月份时候的大放厥词 &#8220;<a
href="http://ixhan.com/2011/04/plans-for-lesslyrics/">LessLyrics歌词秀后续计划</a>&#8221;</p><p>今天写这文章时才发现居然又过去了5个月。这几个月里辞去了百度的工作，和朋友们开始了全新的创业之路，断断续续的也就选择性的忘记了这个升级计划。</p><p>当然还有2个原因，计划的0.8版本中无缝滚动动画效果依赖非常精确的iTunes播放时间，但是能取到最小的间隔是1秒，所以处理起一些细节会比较麻烦。但是呢从当时的预览视频可以看到其实当时完成度已经很高了，在我开心的向datou炫耀这个超级华丽无缝歌词滚动动画效果，结果datou研究了很久后，说了句。不好。</p><p>虽然不愿意承认这么帅气的效果被否决，但仔细想确实有很大的问题。无缝滚动效果会导致整个界面一直处于动画中，当前高亮播放中的歌词也一直在逐渐向上滚动，会导致使用者为了fo这行歌词一直让眼球向上扫描，接着目光聚集到下面的歌词，然后又继续向上扫。看久了就会觉得挺累。</p><p>昨天在我们的app内测qq群中有用户问要显示歌词的软件。我赶紧推荐了LessLyrics，结果人家居然说，居然说，说：“这个app早就知道了！！我想要iPhone版本的”</p><p>于是我爽到现在，于是决定必须立刻重新启动LessLyrics软件计划了！</p><p>新的0.8版本没增加太多的功能，因为迫不及待要发布新版本收集下反馈。这次完全重写了app的设计结构和渲染模块（现在看1年前刚学习mac开发的代码真的很戳），接下来的添加新功能就方便了。</p><p>不用期待，几小时内发布。</p><p>哈哈哈哈哈哈哈哈哈哈哈哈哈哈。</p><p>下载请移步至 <a
target="_blank" title="LessLyrics" href="/lesslyrics/" target="_blank">项目页面</a></p><h3  class="related_post_title">Related Posts</h3><ul
class="related_post"><li><a
href="http://ixhan.com/lesslyrics/download-lyrics-tutorial/" title="Lyrics Tutorial">Lyrics Tutorial</a></li><li><a
href="http://ixhan.com/project/lessdj/" title="LessDJ">LessDJ</a></li><li><a
href="http://ixhan.com/2011/04/plans-for-lesslyrics/" title="LessLyrics 歌词秀后续计划">LessLyrics 歌词秀后续计划</a></li><li><a
href="http://ixhan.com/lesslyrics/" title="LessLyrics">LessLyrics</a></li></ul>]]></content:encoded> <wfw:commentRss>http://ixhan.com/2011/09/lesslyrics-relaunch-now/feed/</wfw:commentRss> <slash:comments>3</slash:comments> </item> <item><title>CrazyText &#8211; My First MacRuby App</title><link>http://ixhan.com/2011/04/crazytext-my-first-macruby-app/</link> <comments>http://ixhan.com/2011/04/crazytext-my-first-macruby-app/#comments</comments> <pubDate>Mon, 18 Apr 2011 15:05:54 +0000</pubDate> <dc:creator>xhan</dc:creator> <category><![CDATA[Coding]]></category> <category><![CDATA[Project]]></category> <category><![CDATA[crazy text]]></category> <category><![CDATA[MacRuby]]></category> <category><![CDATA[opensource]]></category> <guid
isPermaLink="false">http://ixhan.com/?p=539</guid> <description><![CDATA[<a
href="http://ixhan.com/2011/04/crazytext-my-first-macruby-app/" title="CrazyText - My First MacRuby App"><img
width="320" height="200" src="http://ixhan.com/wp-content/uploads/2011/04/crazy_text_screenshot.jpg" class="attachment-extra-featured-image wp-post-image" alt="Crazy Text screenshot" title="Crazy Text screenshot" /></a>前不久听说MacRuby 0.10 发布,并支持了Mac App Store 的发布. 于是边学习Ruby边学习MacRuby边学习cocoa 写了这么一个东西. A MacOSX app written in Macruby to create some funny  effects for your texts. 提交时候提示MacRuby.framework内的几个link位置不对. 忘记什么提示了,需要手动修复几个link文件的地址. 对了1 :源码请移步 github-&#62; https://github.com/xhan/CrazyText 对了2: 可以在appstore下载哦 部分UI仍然使用 objc编写(有些类和方法实在不知道如何用ruby实现) 个人感觉macruby 的学习曲线还真蛮高的,会cocoa,会ruby,还得会MacRuby,非常坑人,而且调试也非常又难度. Related Posts开源项目 LessDJ &#8211; 简约至上的音乐电台DJ永远的扫雷英雄(开源) 登场PlutoCMS! 基于ROR的内容管理系统[iPhone]播放midi文件]]></description> <content:encoded><![CDATA[<a
href="http://ixhan.com/2011/04/crazytext-my-first-macruby-app/" title="CrazyText - My First MacRuby App"><img
width="320" height="200" src="http://ixhan.com/wp-content/uploads/2011/04/crazy_text_screenshot.jpg" class="attachment-extra-featured-image wp-post-image" alt="Crazy Text screenshot" title="Crazy Text screenshot" /></a><p>前不久听说MacRuby 0.10 发布,并支持了Mac App Store 的发布.</p><p>于是边学习Ruby边学习MacRuby边学习cocoa 写了这么一个东西.</p><p>A MacOSX app written in Macruby to create some funny  effects for your texts.</p><p><a
href="http://ixhan.com/wp-content/uploads/2011/04/crazy_text_screenshot1.jpg"><img
class="alignnone size-full wp-image-543" title="Crazy Text" src="http://ixhan.com/wp-content/uploads/2011/04/crazy_text_screenshot1.jpg" alt="" width="576" height="360" /></a></p><p>提交时候提示MacRuby.framework内的几个link位置不对. 忘记什么提示了,需要手动修复几个link文件的地址.</p><p>对了1 :源码请移步 github-&gt; <a
target="_blank" href="https://github.com/xhan/CrazyText" target="_blank">https://github.com/xhan/CrazyText</a></p><p>对了2:</p><p><a
target="_blank" href="http://itunes.apple.com/us/app/crazy-text/id431122700?mt=12"><img
class="alignnone" title="mac app store" src="https://developer.apple.com/appstore/images/available-on-mac-app-store.png" alt="" width="160" height="48" /></a> 可以在<a
target="_blank" href="http://itunes.apple.com/us/app/crazy-text/id431122700?mt=12" target="_blank">appstore</a>下载哦</p><p>部分UI仍然使用 objc编写(有些类和方法实在不知道如何用ruby实现)</p><p>个人感觉macruby 的学习曲线还真蛮高的,会cocoa,会ruby,还得会MacRuby,非常坑人,而且调试也非常又难度.</p><h3  class="related_post_title">Related Posts</h3><ul
class="related_post"><li><a
href="http://ixhan.com/2012/01/opensource-lessdj/" title="开源项目 LessDJ &#8211; 简约至上的音乐电台DJ">开源项目 LessDJ &#8211; 简约至上的音乐电台DJ</a></li><li><a
href="http://ixhan.com/2009/12/minesweeperever/" title="永远的扫雷英雄(开源) 登场">永远的扫雷英雄(开源) 登场</a></li><li><a
href="http://ixhan.com/2009/10/plutocms-ruby-on-rails-cms/" title="PlutoCMS! 基于ROR的内容管理系统">PlutoCMS! 基于ROR的内容管理系统</a></li><li><a
href="http://ixhan.com/2009/10/how-to-let-iphone-play-midi-file/" title="[iPhone]播放midi文件">[iPhone]播放midi文件</a></li></ul>]]></content:encoded> <wfw:commentRss>http://ixhan.com/2011/04/crazytext-my-first-macruby-app/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>UIViewController 的内存管理</title><link>http://ixhan.com/2011/02/uiviewcontroller-memory-manage/</link> <comments>http://ixhan.com/2011/02/uiviewcontroller-memory-manage/#comments</comments> <pubDate>Mon, 28 Feb 2011 15:24:30 +0000</pubDate> <dc:creator>xhan</dc:creator> <category><![CDATA[Coding]]></category> <category><![CDATA[iOS]]></category> <category><![CDATA[memory manage]]></category> <category><![CDATA[UIViewController]]></category> <guid
isPermaLink="false">http://ixhan.com/?p=503</guid> <description><![CDATA[<a
href="http://ixhan.com/2011/02/uiviewcontroller-memory-manage/" title="UIViewController 的内存管理"></a>在iOS3.0后,UIViewController多了一个叫做viewDidUnLoad的方法.不少人都不清楚这个方法的具体意义,苹果的文档也就一句&#8221;Called when the controller’s view is released from memory&#8221;　简单的解释了下,并要求你把IBOutlet绑定的视图给清空,为什么呢? 先看下UIViewController从创建view到展示的流程的几个函数 -init -initWithNibName:bundle: 这两个方法都是初始化一个vc,但请注意view不是这时候载入的 -loadView -viewDidLoad 当一个视图准备展现时,vc首先会判断view是否已经创建,否则便通过之前指定的xib文件来初始化view,以及绑定其他关系(若没有指定xib文件,则默认会搜索和vc同名的xib,比如myNameViewController就会搜索 myNameViewController.xib文件) 若是没有xib文件,你就可以在loadview中自己手动创建这个viewControoler需要的视图. 接下来就是调用到 -viewDidLoad,许多人喜欢在这里做些其他事情,比如做个http请求,建立个数组啥的, 这里若不处理正确,　-viewDidUnload 激活时内存就容易泄露了,稍后提到. -view()appear -view()disappear 这几个方法就不解释了 -viewDidUnload 该方法在收到内存警告,同时该视图并不在当前界面显示时候会被调用,此时该controller的view已经被释放并赋值为nil. 接下来你要做的是 把实例变量的子视图释放(IBOulet的,以及自己添加的),. 其他实例变量,比如之前在-viewDidLoaded中实例的数据数组,http请求释放掉. 因为当该viewController再次被激活准备显示时(比如navigationControler返回到上一级),vc发现自己的view为空后会重复之前的流程直到把view给创建起来,若没将自己额外添加的子视图,各种类实例变量释放,这里便会重新再次创建. 于是,内存泄露了. Related PostsUITableView 离奇滚动到顶部的问题]]></description> <content:encoded><![CDATA[<a
href="http://ixhan.com/2011/02/uiviewcontroller-memory-manage/" title="UIViewController 的内存管理"></a><p>在iOS3.0后,UIViewController多了一个叫做viewDidUnLoad的方法.不少人都不清楚这个方法的具体意义,苹果的文档也就一句&#8221;Called when the controller’s view is released from memory&#8221;　简单的解释了下,并要求你把IBOutlet绑定的视图给清空,为什么呢?</p><p>先看下UIViewController从创建view到展示的流程的几个函数</p><blockquote><p>-init<br
/> -initWithNibName:bundle:</p></blockquote><p>这两个方法都是初始化一个vc,但请注意view不是这时候载入的</p><blockquote><p>-loadView<br
/> -viewDidLoad</p></blockquote><p>当一个视图准备展现时,vc首先会判断view是否已经创建,否则便通过之前指定的xib文件来初始化view,以及绑定其他关系(若没有指定xib文件,则默认会搜索和vc同名的xib,比如myNameViewController就会搜索 myNameViewController.xib文件)</p><p>若是没有xib文件,你就可以在loadview中自己手动创建这个viewControoler需要的视图.<br
/> 接下来就是调用到 -viewDidLoad,许多人喜欢在这里做些其他事情,比如做个http请求,建立个数组啥的, 这里若不处理正确,　-viewDidUnload 激活时内存就容易泄露了,稍后提到.</p><blockquote><p>-view()appear<br
/> -view()disappear</p></blockquote><p>这几个方法就不解释了</p><blockquote><p>-viewDidUnload</p></blockquote><p>该方法在收到内存警告,同时该视图并不在当前界面显示时候会被调用,此时该controller的view已经被释放并赋值为nil.<br
/> 接下来你要做的是</p><ol><li>把实例变量的子视图释放(IBOulet的,以及自己添加的),.</li><li>其他实例变量,比如之前在-viewDidLoaded中实例的数据数组,http请求释放掉.</li></ol><p>因为当该viewController再次被激活准备显示时(比如navigationControler返回到上一级),vc发现自己的view为空后会重复之前的流程直到把view给创建起来,若没将自己额外添加的子视图,各种类实例变量释放,这里便会重新再次创建.</p><p>于是,内存泄露了.</p><h3  class="related_post_title">Related Posts</h3><ul
class="related_post"><li><a
href="http://ixhan.com/2011/09/uitableview-offset-to-top-unexpected/" title="UITableView 离奇滚动到顶部的问题">UITableView 离奇滚动到顶部的问题</a></li></ul>]]></content:encoded> <wfw:commentRss>http://ixhan.com/2011/02/uiviewcontroller-memory-manage/feed/</wfw:commentRss> <slash:comments>8</slash:comments> </item> <item><title>Read UTF8 code at specify position from an NSString</title><link>http://ixhan.com/2011/02/read-utf8-code-at-specify-position-from-an-nsstring/</link> <comments>http://ixhan.com/2011/02/read-utf8-code-at-specify-position-from-an-nsstring/#comments</comments> <pubDate>Thu, 24 Feb 2011 14:19:48 +0000</pubDate> <dc:creator>xhan</dc:creator> <category><![CDATA[Coding]]></category> <category><![CDATA[字符编码]]></category> <category><![CDATA[NSString]]></category> <guid
isPermaLink="false">http://ixhan.com/?p=493</guid> <description><![CDATA[<a
href="http://ixhan.com/2011/02/read-utf8-code-at-specify-position-from-an-nsstring/" title="Read UTF8 code at specify position from an NSString"></a>如何获取nsstring制定某个位置的utf８编码的字符呢? 我也不知道,所以在stackoverflow问了下. 很快就有人回复了解决方案. 在贴代码之前写介绍下几个编码格式: UTF8 和 UTF16均为字符编码方式. UTF-8使用一至四個位元組為每個字符編碼： 128個US-ASCII字符只需一個位元組編碼（Unicode範圍由U+0000至U+007F）。 帶有附加符号的拉丁文、希臘文、西里爾字母、亞美尼亞語、希伯來文、阿拉伯文、敘利亞文及它拿字母則需要二個位元組編碼（Unicode範圍由U+0080至U+07FF）。 其他基本多文種平面（BMP）中的字元（這包含了大部分常用字）使用三個位元組編碼。 其他極少使用的Unicode 輔助平面的字元使用四位元組編碼。 UTF-16是Unicode的其中一個使用方式。UTF是Unicode/UCS Transformation Format，即把Unicode轉做某種格式的意思。 其編碼方法是： 1如果字符編碼U小於0&#215;10000，也就是十進制的0到65535之內，則直接使用兩字節表示； 2如果字符編碼U大於0&#215;10000，由於UNICODE編碼範圍最大為0x10FFFF，從0&#215;10000到0x10FFFF之間 共有0xFFFFF個編碼，也就是需要20個bit就可以標示這些編碼。用U&#8217;表示從0-0xFFFFF之間的值，將其前 10 bit作為高位和16 bit的數值0xD800進行 邏輯or 操作，將後10 bit作為低位和0xDC00做 邏輯or 操作，這樣組成的 4個byte就構成了U的編碼。 而NSString使用的就是unicode存储的,　唯一一个获取unichar的方法叫做 -characterAtIndex: ,　但是问题是 unichar 其实是个 unsigned short,也就是２个字节,所以它并不能展现所有的字符. 终极解决方法: Related PostsObjC中URL编码]]></description> <content:encoded><![CDATA[<a
href="http://ixhan.com/2011/02/read-utf8-code-at-specify-position-from-an-nsstring/" title="Read UTF8 code at specify position from an NSString"></a><p>如何获取nsstring制定某个位置的utf８编码的字符呢?</p><p>我也不知道,所以在<a
target="_blank" href="http://stackoverflow.com/questions/5100030/read-utf8-character-in-specify-position-from-a-nsstring">stackoverflow</a>问了下.</p><p>很快就有人回复了解决方案.</p><p>在贴代码之前写介绍下几个编码格式:</p><p>UTF8 和 UTF16均为字符编码方式.</p><p>UTF-8使用一至四個<a
target="_blank" title="字节" href="http://zh.wikipedia.org/wiki/%E5%AD%97%E8%8A%82">位元組</a>為每個字符編碼：</p><ol><li>128個US-ASCII字符只需一個位元組編碼（Unicode範圍由U+0000至U+007F）。</li><li>帶有<a
target="_blank" href="http://zh.wikipedia.org/wiki/%E9%99%84%E5%8A%A0%E7%AC%A6%E5%8F%B7">附加符号</a>的<a
target="_blank" title="拉丁文" href="http://zh.wikipedia.org/wiki/%E6%8B%89%E4%B8%81%E6%96%87">拉丁文</a>、<a
target="_blank" title="希臘文" href="http://zh.wikipedia.org/wiki/%E5%B8%8C%E8%87%98%E6%96%87">希臘文</a>、<a
target="_blank" title="西里爾字母" href="http://zh.wikipedia.org/wiki/%E8%A5%BF%E9%87%8C%E7%88%BE%E5%AD%97%E6%AF%8D">西里爾字母</a>、<a
target="_blank" title="亞美尼亞語" href="http://zh.wikipedia.org/wiki/%E4%BA%9E%E7%BE%8E%E5%B0%BC%E4%BA%9E%E8%AA%9E">亞美尼亞語</a>、<a
target="_blank" title="希伯來文" href="http://zh.wikipedia.org/wiki/%E5%B8%8C%E4%BC%AF%E4%BE%86%E6%96%87">希伯來文</a>、<a
target="_blank" title="阿拉伯文" href="http://zh.wikipedia.org/wiki/%E9%98%BF%E6%8B%89%E4%BC%AF%E6%96%87">阿拉伯文</a>、<a
target="_blank" title="叙利亚文" href="http://zh.wikipedia.org/wiki/%E5%8F%99%E5%88%A9%E4%BA%9A%E6%96%87">敘利亞文</a>及<a
target="_blank" href="http://zh.wikipedia.org/wiki/%E5%AE%83%E6%8B%BF%E5%AD%97%E6%AF%8D">它拿字母</a>則需要二個位元組編碼（Unicode範圍由U+0080至U+07FF）。</li><li>其他<a
target="_blank" href="http://zh.wikipedia.org/wiki/%E5%9F%BA%E6%9C%AC%E5%A4%9A%E6%96%87%E7%A8%AE%E5%B9%B3%E9%9D%A2">基本多文種平面</a>（BMP）中的字元（這包含了大部分常用字）使用三個位元組編碼。</li><li>其他極少使用的Unicode <a
target="_blank" title="輔助平面" href="http://zh.wikipedia.org/wiki/%E8%BC%94%E5%8A%A9%E5%B9%B3%E9%9D%A2">輔助平面</a>的字元使用四位元組編碼。</li></ol><p><strong>UTF-16</strong>是<a
target="_blank" href="http://zh.wikipedia.org/wiki/Unicode">Unicode</a>的其中一個使用方式。UTF是<em>Unicode/UCS Transformation Format</em>，即把Unicode轉做某種格式的意思。</p><p>其編碼方法是：</p><p>1如果字符編碼U小於0&#215;10000，也就是十進制的0到65535之內，則直接使用兩字節表示；</p><p>2如果字符編碼U大於0&#215;10000，由於UNICODE編碼範圍最大為0x10FFFF，從0&#215;10000到0x10FFFF之間 共有0xFFFFF個編碼，也就是需要20個bit就可以標示這些編碼。用U&#8217;表示從0-0xFFFFF之間的值，將其前 10 bit作為高位和16 bit的數值0xD800進行 邏輯or 操作，將後10 bit作為低位和0xDC00做 邏輯or 操作，這樣組成的 4個byte就構成了U的編碼。</p><p>而NSString使用的就是unicode存储的,　唯一一个获取unichar的方法叫做 -characterAtIndex: ,　但是问题是 unichar 其实是个 unsigned short,也就是２个字节,所以它并不能展现所有的字符.</p><p>终极解决方法:</p><pre>
<pre class="brush: objc; title: ; notranslate">
@interface NSString (UTF8)
- (NSRange) rangeOfUTFCodePoint:(NSUInteger)number;
@end
@implementation NSString (UTF8)
- (NSRange) rangeOfUTFCodePoint:(NSUInteger)number
{
    if (number &gt;= [self length]) {
        return NSMakeRange(NSNotFound, NSNotFound);
    }
    NSUInteger codeUnit = 0;
    NSRange result;
    for(NSUInteger ix = 0; ix &lt;= number; ix++)
    {
        result = [self rangeOfComposedCharacterSequenceAtIndex:codeUnit];
        codeUnit += result.length;
    }
    return result;
}
@end
</pre></pre><h3  class="related_post_title">Related Posts</h3><ul
class="related_post"><li><a
href="http://ixhan.com/2011/09/objective-c-url-encoding/" title="ObjC中URL编码">ObjC中URL编码</a></li></ul>]]></content:encoded> <wfw:commentRss>http://ixhan.com/2011/02/read-utf8-code-at-specify-position-from-an-nsstring/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>关于豆瓣电台osx版</title><link>http://ixhan.com/2010/07/about-douban-radio-osx/</link> <comments>http://ixhan.com/2010/07/about-douban-radio-osx/#comments</comments> <pubDate>Sat, 10 Jul 2010 07:36:47 +0000</pubDate> <dc:creator>xhan</dc:creator> <category><![CDATA[Coding]]></category> <category><![CDATA[douban]]></category> <category><![CDATA[mac]]></category> <guid
isPermaLink="false">http://ixhan.com/?p=370</guid> <description><![CDATA[<a
href="http://ixhan.com/2010/07/about-douban-radio-osx/" title="关于豆瓣电台osx版"></a>突发奇想为什么不做个豆瓣电台的osx版本呢 于是就有了这个开源的项目 http://ixhan.com/project/douban-fm-osx/ 后发现Du Song同学的FanRadio: Free Music For Mac 已做的无懈可击，同时twitter上朋友告诉我dashboard已经支持后台的音乐播放了。 有点多此一举的感觉。= = 不过个人还是喜欢一个原生的播放器浮在桌面上的感觉拉。 原计划0.2版本中会提供解析当前歌手名，歌曲名并可以同步更新至adium的状态，以及歌词显示功能。 坏消息是今天发现从flash中获取到内容相当困难。 好消息是通过抓包发现了豆瓣电台的接口，相当简单。可以做不少好玩的东西去。 Related Posts[Mac]终端中快速定位到Finder的当前路径Mac可以这么玩-用Finder示爱!使用Hamachi和Screen Share远程管理你的MacLessLyrics]]></description> <content:encoded><![CDATA[<a
href="http://ixhan.com/2010/07/about-douban-radio-osx/" title="关于豆瓣电台osx版"></a><p>突发奇想为什么不做个豆瓣电台的osx版本呢</p><p>于是就有了这个开源的项目 <a
href="http://ixhan.com/project/douban-fm-osx/">http://ixhan.com/project/douban-fm-osx/</a></p><p>后发现<cite><a
target="_blank" rel="external nofollow" href="http://blog.rollingcode.org/">Du  Song</a></cite>同学的<a
target="_blank" rel="bookmark" href="http://blog.rollingcode.org/2010/06/20/fanradio-1/">FanRadio:  Free Music For Mac </a>已做的无懈可击，同时twitter上朋友告诉我dashboard已经支持后台的音乐播放了。</p><p>有点多此一举的感觉。= =</p><p>不过个人还是喜欢一个原生的播放器浮在桌面上的感觉拉。</p><p>原计划0.2版本中会提供解析当前歌手名，歌曲名并可以同步更新至adium的状态，以及歌词显示功能。</p><p>坏消息是今天发现从flash中获取到内容相当困难。</p><p>好消息是通过抓包发现了豆瓣电台的接口，相当简单。可以做不少好玩的东西去。</p><h3  class="related_post_title">Related Posts</h3><ul
class="related_post"><li><a
href="http://ixhan.com/2011/12/terminal-fast-switch-dir-to-finder-current-dictionar/" title="[Mac]终端中快速定位到Finder的当前路径">[Mac]终端中快速定位到Finder的当前路径</a></li><li><a
href="http://ixhan.com/2011/04/declaring-love-with-macosx-finder/" title="Mac可以这么玩-用Finder示爱!">Mac可以这么玩-用Finder示爱!</a></li><li><a
href="http://ixhan.com/2011/03/using-hamachi-to-remote-control-macs-anywhere/" title="使用Hamachi和Screen Share远程管理你的Mac">使用Hamachi和Screen Share远程管理你的Mac</a></li><li><a
href="http://ixhan.com/lesslyrics/" title="LessLyrics">LessLyrics</a></li></ul>]]></content:encoded> <wfw:commentRss>http://ixhan.com/2010/07/about-douban-radio-osx/feed/</wfw:commentRss> <slash:comments>3</slash:comments> </item> <item><title>栽大了之Objc过度释放对象</title><link>http://ixhan.com/2009/11/shit-on-objc-object-manager/</link> <comments>http://ixhan.com/2009/11/shit-on-objc-object-manager/#comments</comments> <pubDate>Thu, 26 Nov 2009 09:37:28 +0000</pubDate> <dc:creator>xhan</dc:creator> <category><![CDATA[Coding]]></category> <category><![CDATA[iOS]]></category> <category><![CDATA[apple]]></category> <category><![CDATA[决定]]></category> <category><![CDATA[内存管理]]></category> <category><![CDATA[c]]></category> <category><![CDATA[objective-c]]></category> <guid
isPermaLink="false">http://ixhan.com/?p=196</guid> <description><![CDATA[<a
href="http://ixhan.com/2009/11/shit-on-objc-object-manager/" title="栽大了之Objc过度释放对象"></a>事情是这样的,4个月前我写了份实现类似下拉框选择操作的界面. 一个月前,发现了这个View 在dealloc 会crash掉. 多次调试无果,上 devForum.apple.com 询问也无人问津. 今天决定再次调试下,还是没找到哪里出问题. 最后决定求助 cocoachina 上的现场观众 最后开始一行一行的注释代码做终极调试. 离谱的事情发现了,只要我创建一个名为 mainText 的 UILabel ,在dealloc 中程序就会crash ,改成其他名字无事.难道是apple的bug? 新写了个view测试了,还是没问题. 接着接着就发现了在dealloc方法中: [mainText release] ,mainText = nil; // NSLog(@"release %@",bgView); [bgView release]; // NSLog(@"release %@",originView); [originView release]; // NSLog(@"release %@",labelArray); [labelArray &#8230;<p
class="read-more"><a
href="http://ixhan.com/2009/11/shit-on-objc-object-manager/">Read more &#187;</a></p>]]></description> <content:encoded><![CDATA[<a
href="http://ixhan.com/2009/11/shit-on-objc-object-manager/" title="栽大了之Objc过度释放对象"></a><p>事情是这样的,4个月前我写了份实现类似下拉框选择操作的界面.<br
/> 一个月前,发现了这个View 在dealloc 会crash掉.<br
/> 多次调试无果,上 devForum.apple.com 询问也无人问津.<br
/> 今天决定再次调试下,还是没找到哪里出问题.<br
/> 最后决定求助 cocoachina 上的现场观众<br
/> 最后开始一行一行的注释代码做终极调试.</p><p>离谱的事情发现了,只要我创建一个名为 mainText 的 UILabel ,在dealloc 中程序就会crash ,改成其他名字无事.难道是apple的bug? 新写了个view测试了,还是没问题.</p><p>接着接着就发现了在dealloc方法中:<br
/> <code> [mainText release] ,mainText = nil;<br
/> //	NSLog(@"release %@",bgView);<br
/> [bgView release];<br
/> //	NSLog(@"release %@",originView);<br
/> [originView release];<br
/> //	NSLog(@"release %@",labelArray);<br
/> [labelArray release];<br
/> //	NSLog(@"release %@",mainText);<br
/> [mainText release];<br
/> </code><br
/> 该死的,不知道当时那根神经错了,居然释放了两次,当然出错咯.问题也解决了.</p><p>所以在确认释放对象的情况下一定要写成:<br
/> [instance release],instance = nil ;</p><p>个人经验是,对于objective-c的内存管理都是得经过磨练才出来的,前期多犯错误是好事情.<br
/> 当然我认识一个朋友 ,他不释放任何对象,因为反正关闭iPhone后系统会处理的.这种觉悟不是大部分程序员有的,大家还是稳步前进咯.</p><h3  class="related_post_title">Related Posts</h3><ul
class="related_post"><li><a
href="http://ixhan.com/2009/12/minesweeperever/" title="永远的扫雷英雄(开源) 登场">永远的扫雷英雄(开源) 登场</a></li><li><a
href="http://ixhan.com/2010/04/apple-such-a-bitch/" title="Apple 发疯了">Apple 发疯了</a></li><li><a
href="http://ixhan.com/2009/12/dec-review/" title="12月串烧-年轻人就要飘逸">12月串烧-年轻人就要飘逸</a></li><li><a
href="http://ixhan.com/2009/11/things-ive-done-in-past-5-months/" title="Things I&#8217;ve done int past 5 months">Things I&#8217;ve done int past 5 months</a></li></ul>]]></content:encoded> <wfw:commentRss>http://ixhan.com/2009/11/shit-on-objc-object-manager/feed/</wfw:commentRss> <slash:comments>145</slash:comments> </item> </channel> </rss>
