Ray's playground

 
上一页 1 ··· 11 12 13 14 15 16 17 18 19 ··· 56 下一页

2011年3月11日

Creating NSFormatters(Chapter 26 of Cocoa Programming for Mac OS X)

摘要: 1#import"ColorFormatter.h"23@interfaceColorFormatter()45-(NSString*)firstColorKeyForPartialString:(NSString*)string;67@end89@implementationColorFormatter1011-(id)init12{13[superinit];14colorList=[[NSColorListcolorListNamed:@"Apple"]retain];15returnself;16}1718-(void)dealloc19{20[ 阅读全文

posted @ 2011-03-11 09:19 Ray Z 阅读(220) 评论(0) 推荐(0) 编辑

2011年3月10日

Project Euler Problem 12

摘要: The sequence of triangle numbers is generated by adding the natural numbers. So the 7thtriangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. The first ten terms would be:1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ...Let us list the factors of the first seven triangle numbers:1: 13: 1,36: 1,2,3,610: 1,2 阅读全文

posted @ 2011-03-10 21:19 Ray Z 阅读(196) 评论(0) 推荐(0) 编辑

Project Euler Problem 3

摘要: The prime factors of 13195 are 5, 7, 13 and 29.What is the largest prime factor of the number 600851475143 ?1#include<iostream>2usingnamespacestd;34longlongGetFirstFactor(longlongnum)5{6longlongroot=sqrt((longdouble)num);7for(longlongi=2;i<root;i++)8{9if(num%i==0)10{11returni;12}13}1415retu 阅读全文

posted @ 2011-03-10 20:35 Ray Z 阅读(171) 评论(0) 推荐(0) 编辑

2011年3月8日

Sheets(Chapter 25 of Cocoa Programming for Mac OS X)

摘要: 1//2//AppController.m3//TypingTutor4//5//Createdbyb1mobileon3/3/11.6//Copyright2011__MyCompanyName__.Allrightsreserved.7//89#import"AppController.h"10#import"BigLetterView.h"1112#defineMAX_COUNT(100)13//#defineCOUNT_STEP(5)1415@implementationAppController1617-(id)init18{19[superi 阅读全文

posted @ 2011-03-08 17:36 Ray Z 阅读(189) 评论(0) 推荐(0) 编辑

2011年3月5日

NSTimer(Chapter 24 of Cocoa Programming for Mac OS X)

摘要: 1#import"AppController.h"2#import"BigLetterView.h"34#defineMAX_COUNT(100)5#defineCOUNT_STEP(5)67@implementationAppController89-(id)init10{11[superinit];1213letters=[[NSArrayalloc]initWithObjects:@"a",@"s",@"d",@"f",@"j",@"k&q 阅读全文

posted @ 2011-03-05 13:20 Ray Z 阅读(272) 评论(0) 推荐(0) 编辑

2011年3月3日

Drag-and-Drop(Chapter 23 of Cocoa Programming for Mac OS X)

摘要: #import"BigLetterView.h"@implementationBigLetterView-(NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL)isLocal{returnNSDragOperationCopy|NSDragOperationDelete;}-(NSDragOperation)draggingUpdated:(id<NSDraggingInfo>)sender{NSDragOperationop=[senderdraggingSourceOperationMask]; 阅读全文

posted @ 2011-03-03 10:43 Ray Z 阅读(500) 评论(0) 推荐(1) 编辑

2011年3月2日

Pasteboards and Nil-Targeted Actions(Chapter 21 of Cocoa Programming for Mac OS X)

摘要: 1-(void)writeToPasteboard:(NSPasteboard*)pb2{3[pbdeclareTypes:[NSArrayarrayWithObject:NSStringPboardType]owner:self];4[pbsetString:stringforType:NSStringPboardType];5}67-(BOOL)readFromPasteboard:(NSPasteboard*)pb8{9NSArray*types=[pbtypes];10if([typescontainsObject:NSStringPboardType])11{12NSString*v 阅读全文

posted @ 2011-03-02 09:41 Ray Z 阅读(214) 评论(0) 推荐(1) 编辑

2011年3月1日

Drawing Text With Attributes(Chapter 20 of Cocoa Programming for Mac OS X)

摘要: 1#import"BigLetterView.h"234@implementationBigLetterView56-(IBAction)savePDF:(id)sender7{8NSSavePanel*panel=[NSSavePanelsavePanel];9[panelsetRequiredFileType:@"pdf"];10[panelbeginSheetForDirectory:nilfile:nilmodalForWindow:[selfwindow]modalDelegate:selfdidEndSelector:@selector(di 阅读全文

posted @ 2011-03-01 14:52 Ray Z 阅读(678) 评论(0) 推荐(0) 编辑

2011年2月28日

Keyboard Events(Chapter 19 of Cocoa Programming for Mac OS X)

摘要: 1#import"BigLetterView.h"234@implementationBigLetterView56-(id)initWithFrame:(NSRect)frameRect7{8if(![superinitWithFrame:frameRect])9{10returnnil;11}1213NSLog(@"initializingview");14bgColor=[[NSColoryellowColor]retain];15string=@"";16returnself;17}1819-(void)dealloc20{2 阅读全文

posted @ 2011-02-28 17:03 Ray Z 阅读(401) 评论(0) 推荐(0) 编辑

2011年2月26日

Memory Management(Chapter 3 of Objective-C Phrasebook)

摘要: When you send an object an -autoreleasemessage, it is added to the currently activeNSAutoreleasePool instance. When thisinstance is destroyed, every object added to itis sent a -release message.The -autorelease message is a deferred-release message. You send it to an objectwhen you no longer need a. 阅读全文

posted @ 2011-02-26 21:52 Ray Z 阅读(200) 评论(0) 推荐(0) 编辑

上一页 1 ··· 11 12 13 14 15 16 17 18 19 ··· 56 下一页

导航