摘要:#import<Foundation/Foundation.h>intmain(intargc,constchar*argv[]){@autoreleasepool{//insertcodehere...NSLog(@"Hello,World!");NSArray*array=[NSArrayarrayWithObjects:@"Ray",@"Summer",nil];[arrayenumerateObjectsUsingBlock:^(idobj,NSUIntegeridx,BOOL*stop){NSLog(@"
阅读全文
摘要:1#import"Department.h"2#import"Employee.h"34@implementationDepartment5@dynamicdeptName;6@dynamicemployees;7@dynamicmanager;89/*10-(void)addEmployeesObject:(NSManagedObject*)value{11NSSet*changedObjects=[[NSSetalloc]initWithObjects:&valuecount:1];12[selfwillChangeValueForKey:@
阅读全文
摘要:1#import"MyDocument.h"2#import"DepartmentViewController.h"3#import"EmployeeViewController.h"45@implementationMyDocument67-(id)init8{9[superinit];10viewControllers=[[NSMutableArrayalloc]init];1112ManagingViewController*vc=[[DepartmentViewControlleralloc]init];13[vcsetMan
阅读全文
摘要:1#import"AppController.h"2#defineAWS_ID@"1CKE6MZ6S27EFQ458402"34@implementationAppController56-(id)init7{8self=[superinit];9if(self){10//Initializationcodehere.11}1213returnself;14}1516-(IBAction)fetchBooks:(id)sender17{18[progressstartAnimation:nil];1920NSString*input=[searchFie
阅读全文
摘要:1#import"PeopleView.h"2#import"Person.h"34@implementationPeopleView56-(id)initWithPeople:(NSArray*)persons7{8[superinitWithFrame:NSMakeRect(0,0,700,700)];9people=[personscopy];10attributes=[[NSMutableDictionaryalloc]init];11NSFont*font=[NSFontfontWithName:@"Monaco"size:
阅读全文
摘要: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[
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要:#import"BigLetterView.h"@implementationBigLetterView-(NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL)isLocal{returnNSDragOperationCopy|NSDragOperationDelete;}-(NSDragOperation)draggingUpdated:(id<NSDraggingInfo>)sender{NSDragOperationop=[senderdraggingSourceOperationMask];
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要:1#import"StretchView.h"234@implementationStretchView56-(id)initWithFrame:(NSRect)rect7{8if(![superinitWithFrame:rect])9{10returnnil;11}1213srandom(time(NULL));1415path=[[NSBezierPathalloc]init];16[pathsetLineWidth:3.0];17NSPointp=[selfrandomPoint];18[pathmoveToPoint:p];19inti;20for(i=0;i&l
阅读全文
摘要:#import"StretchView.h"@implementationStretchView-(id)initWithFrame:(NSRect)rect{if(![superinitWithFrame:rect]){returnnil;}srandom(time(NULL));path=[[NSBezierPathalloc]init];[pathsetLineWidth:3.0];NSPointp=[selfrandomPoint];[pathmoveToPoint:p];inti;for(i=0;i<15;i++){p=[selfrandomPoint];[
阅读全文
摘要:Clearly, as you develop and localize many applications, you will develop a set of common translations. It would be handy to have an automated way to get the translated strings into a nib file. This is one of several uses for ibtool. The ibtoolcommand, which is run from the terminal, can list the cl.
阅读全文
摘要:The NSRunAlertPanel() function returns an intthat indicates which button the user clicked. There are global variables for these constants: NSAlertDefaultReturn, NSAlertAlternateReturn, and NSAlertOtherReturn. int NSRunAlertPanel(NSString *title, NSString *msg, NSString *defaultButton, NSString *alt.
阅读全文
摘要:PreferenceControllerCode highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->1#import"PreferenceController.h"234@implementationPreferenceController56NSString*constBNRTableBgColorKey=@"TableBackgroundColor";7NSString*constBNREmptyDocKey=
阅读全文
摘要:Every application comes with a set of defaults from the factory. When a user edits his or her defaults, only the differences between the user's wishes and the factory defaults are stored in the user's defaults database. Thus, every time the application starts up, you need to remind it of the
阅读全文
摘要:PreferenceControllerCode highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->1#import"PreferenceController.h"234@implementationPreferenceController56-(id)init7{8if(![superinitWithWindowNibName:@"Preferences"])9{10returnnil;11}1213returnself;14}1516-(void)w
阅读全文
摘要:Apple decided to make this type of application extremely easy to write: NSArrayControllerwill hold on to an array of objects. Bindings will eliminate much of the glue code that would be necessary to keep the model objects in sync with the views. NSManagedObjectContextwill observe the instance v
阅读全文