MacRuby就是用ruby的方式来写Mac上的app, 其实就是ruby和objective-c的转换,
这是官方的一篇教程.
Developing Cocoa Application Using MacRuby
这里还有一篇简单的中文说明,PDF的, 戳我
ps: 越来越懒了,哎.., 这篇日志纯属为了占位,不然十月份就这样过去了,最近垃圾的英文评论非常猖狂,设了验证码完全没用,每天都要清理,么的,不行就ban ip了
2009-10-09 15:21:15, 721 reviews, comment
send to mailbox
我的MacBook, show一下(额..,那啥,我一向很低调的~~)
仓木麻衣
冰河世纪3
snow leopard壁纸
2009-09-09 22:23:44, 873 reviews, comment
for (int i = 0; i < someLargeNumber; i++) { NSString *string = ...; string = [string lowercaseString]; string = [string stringByAppendingString:...]; NSLog(@“%@”, string); }
for (int i = 0; i < someLargeNumber; i++) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSString *string = ...; string = [string lowercaseString]; string = [string stringByAppendingString:...]; NSLog(@“%@”, string); [pool release]; }
NSString *stringToReturn = nil; for (int i = 0; i < someLargeNumber; i++) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSString *string = ...; string = [string stringByAppendingString:...]; if ([string someCondition]) { stringToReturn = [string retain]; } [pool release]; if (stringToReturn) break; } return [stringToReturn autorelease];
2009-06-02 15:21:21, 1119 reviews, comment
#import "Foundation/Foundation.h" int main(int argc, const char * argv[]) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; //a1是用原始方法初始化创建的,因此a1的内存管理由你负责,下面的变量也是如此, 基本上所有通过init之类方法初始化的变量都需要 自己维护变量的引用计数器,用完就要release NSArray *a1 = [[NSArray alloc] initWithObjects:@"NSArray a1", nil]; //只是把指针赋予a2, 该指针的类型是NSArray, 现在a1和a2所指向的是同一块内存单元,就是指向的数值一样,只是引用不一样,就相当于一个文件你创建了两个快捷方式(或者是linux上的soft link), 因此你修改任何一个值等于同时修改另一个的值 NSArray *a2 = a1; //这里输出结果一样 NSLog([a1 description]); NSLog([a2 description]); NSMutableArray *a3 = [[NSMutableArray alloc] initWithObjects:@"NSMutableArray: a3", nil]; NSMutableArray *a4 = a3; [a3 addObject:@"element2"]; //输出结果一样 NSLog([a3 description]); NSLog([a4 description]); //这里才是像php, ruby中的赋值一样,把a3赋予a5, 不同的指针不同的内存地址引用,完全copy NSMutableArray *a5 = [a3 copy]; [a3 addObject:@"element3"]; //只有a5中有element3 NSLog([a3 description]); NSLog([a5 description]); NSMutableArray *a6 = [[NSMutableArray alloc] init]; //把a3中的元素放入a6, 这里只是数据的放入,不会保留mutable和immutable信息 [a6 addObjectsFromArray:a3]; //注意下面的autorelease, 即把含有a, b的数组加入a6中后,自行释放,就是交给程序去管理了 [a6 addObject:[[[NSArray alloc] initWithObjects:@"a", @"b", nil] autorelease]]; NSLog([a6 description]); NSLog([[a6 objectAtIndex:[a6 count] - 1] description]); //创建a6的可变拷贝赋给a7, 只有有mutable, immutable区分的对象才有mutableCopy方法, 即如果这个地方你用的是copy即使a6是mutable, a7也是immutable NSMutableArray *a7 = [a6 mutableCopy]; [a6 insertObject:@"element4" atIndex:3]; NSLog([a6 description]); [a7 insertObject:@"first" atIndex:0]; //this will be error, because the last element is not mutable array //[[a7 objectAtIndex:[a7 count] - 1] addObject:@"c"]; //this will create the mutable copy //上面注释掉的操作是会出错的,因为a, b数组是immutable, 下面就是创建它的mutable拷贝, 也就是iPhone基础开发教程 8.7开始那个函数实际要做的,只是它是递归调用的 NSMutableArray *ma = [[a6 objectAtIndex:[a6 count] -1] mutableCopy]; [a7 replaceObjectAtIndex:[a7 count] - 1 withObject:ma]; //现在就可以操作了 [[a7 objectAtIndex:[a7 count] - 1] addObject:@"c"]; NSLog([a7 description]); //上面的变量哪些要手工release, 哪些由release pool管理,就不多说了 [a1 release]; [a3 release]; [a5 release]; [a6 release]; [a7 release]; [ma release]; [pool release]; return 0; }
2009-05-14 14:40:47, 1581 reviews, comment
今天在做实验时GDB 抛出了EXC_BAD_ACCESS异常,模拟器退出,google得到了结果,内存管理的问题,之前一直是用php, ruby,从没关心过内存的问题,现在真是头疼,需要自己维护变量,不过这样的确可以更深入的了解程序内部的流程,php,ruby把底层的东西都给你隐藏起来了,虽然之前看过不少objc内存管理的内容了,不过熟练的话需要一定实践了,下面是要注意的几点:
Finding EXC_BAD_ACCESS bugs in a Cocoa project
EXC_BAD_ACCESS signal received on iPhone App deployment to device
2009-05-09 13:27:23, 1413 reviews, comment
真不知道CSS3和HTML5能普及是什么时候的事了, 看到CSS3和HTML5的强大,真是感叹现在web的复杂,safari目前对CSS3的支持是最好的,在iphone上开发web应用的可以尝鲜了,下面有篇不错的介绍CSS3的文章可以参考下,
摸我 , 再摸我
2009-05-06 14:55:15, 746 reviews, comment
少年,不点下广告吗!
all by shitou
blog comments powered by Disqus