http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&langpair=en|zh&q=%@

 

参数langpair:前面的是查询的语言,“|”分隔后的是翻译的语言

参数q:要翻译的语句 

 

posted @ 2011-04-27 13:02 tony508 阅读(41) 评论(0) 编辑

相信大家做iphone开发都遇到过内存吃紧的问题,最要命的是不知道究竟自己刚写的这段代码用了多少内存(被instrument骗过好多次了),下面贴出我常用的查看现有内存方法

代码
- (double)availableMemory {
    vm_statistics_data_t vmStats;
    mach_msg_type_number_t infoCount 
= HOST_VM_INFO_COUNT;
    kern_return_t kernReturn 
= host_statistics(mach_host_self(), HOST_VM_INFO, (host_info_t)&vmStats, &infoCount);
    
    
if(kernReturn != KERN_SUCCESS) {
        
return NSNotFound;
    }
    
//vmStats.wire_count
    
//vmStats.inactive_count
    
//vmStats.active_count
    return ((vm_page_size * vmStats.free_count) / 1024.0/ 1024.0;
}

 

以下是相关内存用语的名词解释 

 

Free memory

This is RAM that's not being used.
 

Wired memory

Information in this memory can't be moved to the hard disk, so it must stay in RAM. The amount of Wired memory depends on the applications you are using.
 

Active memory

This information is currently in memory, and has been recently used.
 

Inactive memory

This information in memory is not actively being used, but was recently used.

For example, if you've been using Mail and then quit it, the RAM that Mail was using is marked as Inactive memory. This Inactive memory is available for use by another application, just like Free memory.  However, if you open Mail before its Inactive memory is used by a different application, Mail will open quicker because its Inactive memory is converted to Active memory, instead of loading Mail from the slower hard disk.
 

Used

This is the total amount of memory used.
 

VM size

This is the total amount of Virtual Memory for all processes on your Mac. 
 

Page ins / Page outs

This refers to the amount of information moved between RAM and the hard disk. This number is a cumulative amount of data that Mac OS X has moved between RAM and disk space.

Tip: Page outs occur when your Mac has to write information from RAM to the hard drive (because RAM is full).  Adding more RAM may reduce page outs.
 

Swap used

This is the amount of information copied to the swap file on your hard drive.


(更多内存使用信息可查阅苹果开发文档:Memory Usage Performance Guidelines )

 

 

 

posted @ 2011-01-28 10:55 tony508 阅读(227) 评论(0) 编辑
-(void) initAndPlay:(NSString *)videoURL{
    if(!videoURL)return;
    NSURL*URL=[NSURL URLWithString:[(NSString*) CFURLCreateStringByAddingPercentEscapes(NULL, (CFStringRef)videoURL, NULL, NULL, kCFStringEncodingUTF8) autorelease]];
    if (URL) {
        double ver=[[[UIDevice currentDevice] systemVersion] doubleValue];
        if (ver >= 3.2)
        {
            [moviePlayViewController release];
            moviePlayViewController=[[MPMoviePlayerViewController alloc] initWithContentURL:URL];
            if (moviePlayViewController)
            {
                [self presentMoviePlayerViewControllerAnimated:moviePlayViewController];
                moviePlayViewController.moviePlayer.movieSourceType = MPMovieSourceTypeFile;
                [moviePlayViewController.moviePlayer play];
            }
        }
        else if(ver < 3.2)
        {
            [moviePlayViewController release];
            moviePlayViewController=[[MPMoviePlayerController alloc] initWithContentURL:URL];
            if (moviePlayViewController)                      
            {
                [moviePlayViewController play];
            }
        }
    }

}

 

 [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"telprompt://123456"]]];

 

posted @ 2011-01-19 09:43 tony508 阅读(115) 评论(0) 编辑

   其实很早以前就有想写个博客的想法,只是没想到最后确是因为老板逼着写才真正开始动手,哼~。别人的博客文章是看了很多的,有的是上网搜解决方案,有的是闲着无聊打发时间,有的是关注某某人,受益还是很多的。也不是不想分享,就是感觉没有可以分享的,更怕误人子弟。反复想想,就算自己当个骗子也很难骗到别人,所以就算写错了点什么也无非就是挺胸抬头挨挨板砖就是了,再说也不一定有人读,读了也不一定回,那就当个小学生吧。

 首先免不了当然得自我介绍了,好给读者一个参照,知道这家伙是个什么水平,是个什么东西。我大学学的是软件工程,毕业三年了,现在一家小公司做iphone的项目包工头吧。 原来是做.NET的,iphone开发做了三个多月。每天顶着老板的压力,听着同是刚开始做iphone开发的同事的抱怨,一边搞“技术探索”,一边做着算不上管理的项目管理,一边屁颠屁颠的写着代码。用曾经老板说同事的一句话就是“你一天活在混乱之中吗?”,我很有感觉他是说给我听的。老板总是在递增式的加压,我是一路带着大家低头裸奔。总幻想着有一天,自己一觉醒来技术有了飞越,写起代码来手指像跳动的音符一样轻快有节奏,那样的美妙,无休无止。但现实确总是事与愿违,老板总是告诉你,你做的事是多么的简单,同事总是告诉你,你交给他的东西有多么困难。你要做的要么是告诉老板他要做的事,很难,要么是教给同事他要做的事,其实很简单。 我相信大部分人都会选择后者了,这就要求自身的技术能力快速提升了。

 现在我带着这种迫切的愿望和大家一起努力,展现自我,实现自我。

posted @ 2010-03-21 22:41 tony508 阅读(83) 评论(1) 编辑