
Put the vertical cursor in front of the code line which you will select.
Then click "command + shift + right" keys.
人活着到底怎么算是快乐!! 何为理想!!





// Init the back button
UIBarButtonItem *backBarButtonItem = [[[UIBarButtonItem alloc]
initWithTitle:@"Book Ride"
style:UIBarButtonItemStylePlain
target:nil action:nil] autorelease];
self.navigationItem.backBarButtonItem = backBarButtonItem;
// Init the left button
UIBarButtonItem *leftBarButtonItem = [[[UIBarButtonItem alloc]
initWithTitle:@"Home"
style:UIBarButtonItemStylePlain
target:self action:@selector(cancelAction)] autorelease];
self.navigationItem.leftBarButtonItem = leftBarButtonItem;
UIBarButtonItem *barButton = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemCompose
target:self action:@selector(compose:)];
self.navigationItem.rightBarButtonItem = barButton;
// init the done Button
UIButton *doneButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
doneButton.frame = CGRectMake(0.0, 0.0, 60.0, 30.0);
[doneButton setTitle:@"Done" forState:UIControlStateNormal];
[doneButton setTitleColor:BUTTON_TITLE_COLOR forState:UIControlStateNormal];
[doneButton setBackgroundImage:[UIImage imageNamed:@"bg-principalbtn-curves.png"] forState:UIControlStateNormal];
[doneButton addTarget:self action:@selector(doneActive) forControlEvents:UIControlEventTouchUpInside];
- (void) LoadBigImag
{
if(myImage == nil){
myImage = [self loadSomeBigImageFromSource];
}
}
-(NSArray *) showSomething
{
NSArray *myArray = [NSArray array];
NSArray *aArray = [[NSArray alloc] Init];
NSArray *bArray = [[NSArray alloc] Init];
if(myArray ...)
{
myArray = aArray;
[aArray release];
return myArray;
}
.....
[aArray release];
[bArray release];
return myArray;
}
for (int i=0; i<999999; i++){
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSString *string = @"Memory Test";
string = [string lowercaseString];
string = [string stringByAppendingFormat:@"%d"];
[pool release];
}
<.country>
<.name>中国<./name>
<.province>
<.name>黑龙江<./name>
<.citys>
<.city>哈尔滨<./city>
<.city>大庆<./city>
<./citys>
<./province>
<.province>
<.name>广东<./name>
<.citys>
<.city>广州<./city>
<.city>深圳<./city>
<.city>珠海<./city>
<./citys>
<./province>
<.province>
<.name>台湾<./name>
<.citys>
<.city>台北<./city>
<.city>高雄<./city>
<./citys>
<./province>
<.province>
<.name>新疆<./name>
<.citys>
<.city>乌鲁木齐<./city>
<./citys>
<./province>
<./country>
用JSON表示如下:
{
name:"中国",
province:[
{
name:"黑龙江",
citys:{
city:["哈尔滨","大庆"]
}
},
{
name:"广东",
citys:{
city:["广州","深圳","珠海"]
}
},
{
name:"台湾",
citys:{
city:["台北","高雄"]
}
},
{
name:"新疆",
citys:{
city:["乌鲁木齐"]
}
}
]
}


#import
#import "PolygonShape.h"
//sample function for one section, us a similar function per section
//返回用户路径
void printPathInfo()
{
NSString *path = @"~";
path = [path stringByExpandingTildeInPath];
NSArray *pathComponents = [path pathComponents];
NSLog(@"My home folder is at '%@'",path);
NSLog(@"%@",pathComponents);
}
//返回本程序进程名与ID
void PrintProcessInfo()
{
NSString *processName = [[NSProcessInfo processInfo] processName];
int processIdentifier = [[NSProcessInfo processInfo] processIdentifier];
NSLog(@"Process Name: '%@' Process ID: '%d'",processName,processIdentifier);
}
//书签&&字典
void PrintBookmarkInfo()
{
NSArray *keys = [NSArray arrayWithObjects:@"Stanford University", @"Apple", @"CS193P",@"Stanford on iTunes U", @"Stanford Mail", nil];
NSArray *objects = [NSArray arrayWithObjects:@"http://www.stanford.edu", @"http://www.apple.com", @"http://cs193p.stanford.edu", @"http://itunes.stanford.edu", @"http://stanfordshop.com", nil];
NSDictionary *dictionary = [NSDictionary dictionaryWithObjects:objects forKeys:keys];
int length = [dictionary count];
//NSLog(@"%d",length);
/*
for (id key in dictionary)
{
NSLog(@"Key: %@, URL: %@", key, [dictionary objectForKey:key]);
}*/
for(int i=0;i
{
NSString *aString =@"Stanford";
id buffer = [[dictionary allKeys]objectAtIndex:i];
if([buffer hasPrefix:aString])
NSLog(@"Key: %@, URL %@", buffer,[dictionary objectForKey:buffer]);
}
}
//Class 识别(数组应用)
void PrintIntrospectionInfo()
{
NSMutableArray *array = [[NSMutableArray alloc]init];
NSString *obj1 = @"Iphone Beginner";
NSURL *obj2 = [[NSURL alloc]initWithString:@"www.apple.com" ];
NSProcessInfo *obj3 = [NSProcessInfo processInfo];
[array addObject:obj1];
[array addObject:obj2];
[array addObject:obj3];
int count = [array count];
for(int i=0;i
{
id obj = [array objectAtIndex:i];
NSLog(@"Class Name: %@",[obj className]);
if([obj isMemberOfClass:[NSString class]])
NSLog(@"Is Member of NSString: YES");
else
NSLog(@"Is Member of NSString: NO");
if([obj isKindOfClass:[NSString class]])
NSLog(@"IS Kind of NSString: YES");
else
NSLog(@"Is Kind of NSString: NO");
if([obj respondsToSelector:@selector(lowercaseString)])
{
NSLog(@"Responds to lowercaseString: YES");
NSLog(@"lowercaseString is: %@",[obj performSelector:@selector(lowercaseString)]);
}
else
NSLog(@"Responds to lowercaseString: NO");
NSLog(@"================================================");
}
}
//多边形
void PrintPolygonInfo()
{
PolygonShape *square = [[PolygonShape alloc]init];
[square initWithNumberOfSides:4 minimumNumberOfSides:3 maximumNumberOfSides:7];
PolygonShape *hexagon = [[PolygonShape alloc]initWithNumberOfSides:6 minimumNumberOfSides:5 maximumNumberOfSides:9];
PolygonShape *dodecagon = [[PolygonShape alloc]initWithNumberOfSides:12 minimumNumberOfSides:9 maximumNumberOfSides:12];
NSLog(@"%@",[square description]);
NSLog(@"%@",[hexagon description]);
NSLog(@"%@",[dodecagon description]);
}
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
printPathInfo(); //Section1
PrintProcessInfo(); //Section2
PrintBookmarkInfo(); //Section3
PrintIntrospectionInfo(); //Section4
PrintPolygonInfo(); //Section6
//NSLog(@"Hello world");
[pool drain];
return 0;
}
//
// PolygonShape.h
// WhatATool
//
// Created by Nono on 29/12/2008.
// Copyright 2008 user. All rights reserved.
//
#import
@interface PolygonShape : NSObject
{
int numberOfSides;
int minimumNumberOfSides;
int maximumNumberOfSides;
}
@property int numberOfSides;
@property int minimumNumberOfSides;
@property int maximumNumberOfSides;
@property (readonly) float angleInDegrees;
@property (readonly) float angleInRadians;
@property (readonly) NSString *name;
-(id)initWithNumberOfSides:(int)sides minimumNumberOfSides:(int)min maximumNumberOfSides:(int)max;
@end
//
// PolygonShape.m
// WhatATool
//
// Created by Nono on 29/12/2008.
// Copyright 2008 user. All rights reserved.
//
#import "PolygonShape.h"
@implementation PolygonShape
@synthesize numberOfSides;
@synthesize minimumNumberOfSides;
@synthesize maximumNumberOfSides;
-(id)init
{
[self initWithNumberOfSides:5 minimumNumberOfSides:3 maximumNumberOfSides:10];
return self;
}
-(id)initWithNumberOfSides:(int)sides minimumNumberOfSides:(int)min maximumNumberOfSides:(int)max
{
self = [super init];
[self setMinimumNumberOfSides:min];
[self setMaximumNumberOfSides:max];
[self setNumberOfSides:sides];
NSLog(@"The Minimum of sides is: %d, The Maximum of sides is: %d, The sides of the Polygon is: %d",min,max,sides);
return self;
}
-(void) setMinimumNumberOfSides: (int)min
{
if(min<2)
{
NSLog(@"Invalid number of minimumNumberOfSides: %d is less than 2",min);
}
else
{
minimumNumberOfSides = min;
}
}
-(void) setMaximumNumberOfSides: (int)max
{
if(max>12)
{
NSLog(@"Invalid number of maximunberOfSides: %d is greater than 12",max);
}
else
{
maximumNumberOfSides = max;
}
}
-(void) setNumberOfSides: (int)sides
{
if(sides{
NSLog(@"Invalid number of sides: %d is less than the minimum of %d allowed",sides,minimumNumberOfSides);
}
else if(sides>maximumNumberOfSides)
{
NSLog(@"Invalid number of sides: %d is greater than the maxinmum of %d allowed",sides,maximumNumberOfSides);
}
else
{
numberOfSides = sides;
NSLog(@"Number of sides: %d",sides);
}
}
-(float) angleInDegrees
{
float angleInDegrees = (180*(numberOfSides-2)/numberOfSides);
return angleInDegrees;
}
-(float) angleInRadians
{
float Pi = 3.141592;
float angleInRadians = [self angleInDegrees]/180*Pi;
return angleInRadians;
}
-(NSString *)name
{
NSString *nameArray[] = {nil,@"Henagon", @"Digon", @"Triangle",@"Square", @"Pentagon", @"Hexagon",
@"Heptagon",@"Octagon",@"Enneagon",@"Decagon",@"Hendecagon",@"Dodecagon",nil};
return nameArray[numberOfSides];
}
-(NSString *)description
{
return [NSString stringWithFormat:@"Hello I am a %d-sides polygon ('%@') with angles of %f degrees (%f radians).",[self numberOfSides],[self name],[self angleInDegrees],[self angleInRadians]];
}
@end








招募热心网友一起翻译CS193P了,以文会友
管理提醒: 本帖被 nono 执行置顶操作(2009-10-13)
CS193P中文字幕自发表以来,得到广大网友的积极响应。很多网友鼓励我把这项很有意义的工作坚持下去,但是本人俗事缠身,深感力有未逮,这里特招募热心的网友们,奉献您的才智,和我一起完成这项工作。
加入这项计划,首先需要您的无私奉献。您需要付出巨大的精力,失去一些陪伴家人和朋友的时间,在计划时间内完成听辨,翻译工作。
加入这项计划,你可以巩固自己对iPhone开发的理解,系统地整理自己知识,你把自己的知识和技能告诉了其他人,会得到他们的反馈,投之以桃,报之以李,从而促进你更深的理解iPhone开发。
加入这项计划,毫无疑问您会交到很多的朋友。和你一起翻译的战友会欣赏您的才华,无数的观众甚至可能成为您的粉丝。您的人际网络由此而扩展,单身的您甚至有可能收获自己的另一半。
另外说一句,本计划已经得到Apple工程师的大力支持。本人给Standford大学发了邮件,Alan Cannistraro,CS193P的主讲之一,回信说他们正考虑怎样把字幕加入到课程中,让更多的人从中受益。
有兴趣的,请和我联系。
其实完成这个工作不仅是需要听力好的人,还有很多其他事情要做。我简单地把翻译的流程总结为:
1)听力。把视频中的英文整理出来
2)时间轴矫正。就是为字幕加上时间信息,使它和视频同步。这个可以和1)合并
3)把英文字幕翻译成中文
4)审核,校对
如果有人都上述任何一项有兴趣,都欢迎加入。
感谢Nono帮我把帖子置顶,而且他答应帮我们整理教程作业。非常热心的同学。

- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
// Your view is about to move onscreen
[self beginLoadingDataFromTheWeb];
[self startShowingLoadingProgress];
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
// Your view is about to move offscreen
[self saveDataToDisk];
}
LoadingViewController *lvc = [[LoadingViewController alloc]
initWithTitle:self.title Description:@"Registering User"];
UINavigationController *nc = [[UINavigationController alloc] initWithRootViewController:lvc];
nc.navigationBar.barStyle = UIBarStyleBlackOpaque;
[self.navigationController presentModalViewController:nc animated:NO];
[lvc release];
[nc release];