├── xibs ├── .DS_Store ├── MainViewController.xib └── WordsViewController.xib ├── Classes ├── Config.h ├── THButton.h ├── MKWebService_1.1.0 │ ├── readme.txt │ ├── MKWebService.h │ ├── MKServiceManager.h │ ├── MKServiceManager.m │ └── MKWebService.m ├── WordNote.m ├── MKDicAppDelegate.h ├── THButton.m ├── CustomViewControllerProtocol.h ├── WordNote.h ├── GeneralManager.h ├── CutomerTextView.h ├── StudyViewController.h ├── MainViewController.h ├── WordsViewController.h ├── MKDicAppDelegate.m ├── WordNoteDao.h ├── SentenceViewController.h ├── TouchJSON │ ├── Extensions │ │ ├── NSCharacterSet_Extensions.h │ │ ├── NSDictionary_JSONExtensions.h │ │ ├── CDataScanner_Extensions.h │ │ ├── NSDictionary_JSONExtensions.m │ │ ├── NSScanner_Extensions.h │ │ ├── NSCharacterSet_Extensions.m │ │ ├── CDataScanner_Extensions.m │ │ └── NSScanner_Extensions.m │ ├── JSON │ │ ├── CJSONSerializer.h │ │ ├── CJSONScanner.h │ │ ├── CJSONDeserializer.h │ │ ├── CJSONDeserializer.m │ │ ├── CJSONSerializer.m │ │ └── CJSONScanner.m │ ├── CDataScanner.h │ └── CDataScanner.m ├── CutomerTextView.m ├── GeneralManager.m ├── WordNoteDao.m ├── SentenceViewController.m ├── StudyViewController.m ├── MainViewController.m ├── GDataXML │ └── GDataXMLNode.h └── WordsViewController.m ├── English.lproj ├── InfoPlist.strings └── .DS_Store ├── images ├── .DS_Store ├── big_A.png ├── small_A.png ├── interact.icns ├── sentence_talk.png └── sentence_change.png ├── .gitignore ├── MKDic.xcodeproj ├── xcuserdata │ └── mac.xcuserdatad │ │ ├── xcdebugger │ │ └── Breakpoints.xcbkptlist │ │ └── xcschemes │ │ ├── xcschememanagement.plist │ │ └── MKDic.xcscheme ├── project.xcworkspace │ └── contents.xcworkspacedata └── tanhao.pbxuser ├── MKDic_Prefix.pch ├── main.m ├── readme.txt ├── CutomerTextView.h ├── MainViewController.h ├── Credits.rtf └── MKDic-Info.plist /xibs/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tanhaogg/MiniDic/HEAD/xibs/.DS_Store -------------------------------------------------------------------------------- /Classes/Config.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | #define kNotificationSearchWorld @"NotificationSearchWorld" -------------------------------------------------------------------------------- /English.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /images/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tanhaogg/MiniDic/HEAD/images/.DS_Store -------------------------------------------------------------------------------- /images/big_A.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tanhaogg/MiniDic/HEAD/images/big_A.png -------------------------------------------------------------------------------- /images/small_A.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tanhaogg/MiniDic/HEAD/images/small_A.png -------------------------------------------------------------------------------- /images/interact.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tanhaogg/MiniDic/HEAD/images/interact.icns -------------------------------------------------------------------------------- /English.lproj/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tanhaogg/MiniDic/HEAD/English.lproj/.DS_Store -------------------------------------------------------------------------------- /images/sentence_talk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tanhaogg/MiniDic/HEAD/images/sentence_talk.png -------------------------------------------------------------------------------- /images/sentence_change.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tanhaogg/MiniDic/HEAD/images/sentence_change.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | .DS_Store 3 | .DS_Store 4 | Classes/.DS_Store 5 | MKDic.xcodeproj/project.xcworkspace/xcuserdata/mac.xcuserdatad/UserInterfaceState.xcuserstate 6 | -------------------------------------------------------------------------------- /MKDic.xcodeproj/xcuserdata/mac.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /MKDic_Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'MKDic' target in the 'MKDic' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #import "config.h" 8 | #endif 9 | -------------------------------------------------------------------------------- /MKDic.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Classes/THButton.h: -------------------------------------------------------------------------------- 1 | // 2 | // THButton.h 3 | // Vdisk 4 | // 5 | // Created by Hao Tan on 12/02/08. 6 | // Copyright (c) 2012年 tanhao. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface THButton : NSButton 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // MKDic 4 | // 5 | // Created by stm on 11-6-16. 6 | // Copyright 2011 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | int main(int argc, char *argv[]) 12 | { 13 | return NSApplicationMain(argc, (const char **) argv); 14 | } 15 | -------------------------------------------------------------------------------- /readme.txt: -------------------------------------------------------------------------------- 1 | 本软件由作者学习及交流所用,任何组织和个人不得用作商业用途,由此出现的法律后果自负! 2 | 欢迎你向作者提出宝贵的建议和意见:谭颢 http://www.tanhao.me 3 | 4 | 3.0 更新内容: 5 | 6 | 1.修正了因为谷歌翻译API停用导致翻译不能使用的问题; 7 | 2.将翻译引擎修改为微软的API,翻译速度更快捷; 8 | 3.增加了系统服务,在任何地方右键既可查询翻译(需要重启生效); 9 | 10 | 2.0 更新内容: 11 | 12 | 1.加入了学习功能; 13 | 2.加入生词本的功能; 14 | 3.在查询结果中二次查询; 15 | 4.在查询过程中前进后退的功能; -------------------------------------------------------------------------------- /Classes/MKWebService_1.1.0/readme.txt: -------------------------------------------------------------------------------- 1 | // 2 | // MKWebService 3 | // 4 | 5 | 6 | 7 | 历史版本: 8 | 9 | 1.1.0 10 | 1.原方法uploadWithURL:delegate:blob:key:context:变更为方法uploadWithURL:delegate:postDic:context:,更具有普适应性。 11 | 2.MKWebService对象中的私有方法generateFormData增加了对NSNumber的支持。 12 | 3. generateFormData方法中默认的编码格式修正为UTF-8,并且可以修改。 13 | 14 | 1.0.0 15 | 与服务器之间的上传下载、同步的功能 16 | 17 | -------------------------------------------------------------------------------- /Classes/WordNote.m: -------------------------------------------------------------------------------- 1 | // 2 | // WordNote.m 3 | // MKDic 4 | // 5 | // Created by 谭 颢 on 11-6-20. 6 | // Copyright 2011 天府学院. All rights reserved. 7 | // 8 | 9 | #import "WordNote.h" 10 | 11 | 12 | @implementation WordNote 13 | @synthesize row; 14 | @synthesize level; 15 | @synthesize word; 16 | @synthesize translate; 17 | 18 | - (void)dealloc{ 19 | if(word!=nil) [word release]; 20 | if(translate!=nil) [translate release]; 21 | [super dealloc]; 22 | } 23 | @end 24 | -------------------------------------------------------------------------------- /Classes/MKDicAppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // MKDicAppDelegate.h 3 | // MKDic 4 | // 5 | // Created by stm on 11-6-16. 6 | // Copyright 2011 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class MainViewController; 12 | @interface MKDicAppDelegate : NSObject { 13 | NSWindow *window; 14 | MainViewController *mainViewController; 15 | } 16 | 17 | @property (assign) IBOutlet NSWindow *window; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /Classes/THButton.m: -------------------------------------------------------------------------------- 1 | // 2 | // THButton.m 3 | // Vdisk 4 | // 5 | // Created by Hao Tan on 12/02/08. 6 | // Copyright (c) 2012年 tanhao. All rights reserved. 7 | // 8 | 9 | #import "THButton.h" 10 | 11 | @implementation THButton 12 | 13 | - (void)awakeFromNib 14 | { 15 | [super awakeFromNib]; 16 | } 17 | 18 | - (void)resetCursorRects 19 | { 20 | [super resetCursorRects]; 21 | [self addCursorRect:[self bounds] cursor:[NSCursor pointingHandCursor]]; 22 | } 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /Classes/CustomViewControllerProtocol.h: -------------------------------------------------------------------------------- 1 | // 2 | // CustomViewControllerProtocol.h 3 | // MKDic 4 | // 5 | // Created by 谭 颢 on 11-6-16. 6 | // Copyright 2011 天府学院. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | @protocol CustomViewControllerProtocol 13 | @required 14 | - (void)setFirstResponder; 15 | - (void)changeFont:(NSFont *)aFont; 16 | 17 | - (void)undoAction; 18 | - (void)redoAction; 19 | 20 | - (void)quickTranslateWithString:(NSString *)str; 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /Classes/WordNote.h: -------------------------------------------------------------------------------- 1 | // 2 | // WordNote.h 3 | // MKDic 4 | // 5 | // Created by 谭 颢 on 11-6-20. 6 | // Copyright 2011 天府学院. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | @interface WordNote : NSObject { 13 | int row; 14 | int level; 15 | NSString *word; 16 | NSString *translate; 17 | } 18 | @property (nonatomic, assign) int row; 19 | @property (nonatomic, assign) int level; 20 | @property (nonatomic, retain) NSString *word; 21 | @property (nonatomic, retain) NSString *translate; 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /Classes/GeneralManager.h: -------------------------------------------------------------------------------- 1 | // 2 | // GeneralManager.h 3 | // MKDic 4 | // 5 | // Created by stm on 11-6-16. 6 | // Copyright 2011 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | @interface GeneralManager : NSObject { 13 | NSSpeechSynthesizer *speechSynth; 14 | } 15 | 16 | + (id)shareManager; 17 | + (void)end; 18 | 19 | - (void)speakWithText:(NSString *)aText; 20 | - (void)stopSpeak; 21 | //转换转义字符(暂时没用,保留此处以备后用) 22 | - (NSString *)stringFromEscapes:(NSString *)aString; 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /CutomerTextView.h: -------------------------------------------------------------------------------- 1 | // 2 | // CutomerTextView.h 3 | // MKDic 4 | // 5 | // Created by stm on 11-6-16. 6 | // Copyright 2011 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | @protocol CustomerTextViewDelegate; 13 | @interface CutomerTextView : NSTextView{ 14 | id delegate; 15 | } 16 | @property (nonatomic, assign)id delegate; 17 | @end 18 | 19 | 20 | @protocol CustomerTextViewDelegate 21 | 22 | - (void)enterClick:(id)sender; 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /MainViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // MainViewController.h 3 | // MKDic 4 | // 5 | // Created by stm on 11-6-16. 6 | // Copyright 2011 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class WordsViewController; 12 | @class SentenceViewController; 13 | @interface MainViewController : NSViewController { 14 | IBOutlet NSButton *changeButton; 15 | 16 | WordsViewController *wordsViewController; 17 | SentenceViewController *sentenceViewController; 18 | } 19 | 20 | - (IBAction)changeClick:(NSButton *)sender; 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /Classes/CutomerTextView.h: -------------------------------------------------------------------------------- 1 | // 2 | // CutomerTextView.h 3 | // MKDic 4 | // 5 | // Created by stm on 11-6-16. 6 | // Copyright 2011 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | @protocol CustomerTextViewDelegate; 13 | @interface CutomerTextView : NSTextView{ 14 | id delegate; 15 | } 16 | @property (nonatomic, assign)id delegate; 17 | @end 18 | 19 | 20 | @protocol CustomerTextViewDelegate 21 | 22 | - (void)enterClick:(id)sender; 23 | - (void)rightMenuItemClick:(NSString *)aText; 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /MKDic.xcodeproj/xcuserdata/mac.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | MKDic.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 8D1107260486CEB800E47090 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /Classes/StudyViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // StudyViewController.h 3 | // MKDic 4 | // 5 | // Created by stm on 11-6-17. 6 | // Copyright 2011 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "CustomViewControllerProtocol.h" 11 | 12 | @interface StudyViewController : NSViewController { 14 | IBOutlet NSTableView *currentTableView; 15 | IBOutlet NSTextView *studyTextView; 16 | NSMutableArray *objArray; 17 | } 18 | @property (nonatomic,retain) NSMutableArray *objArray; 19 | 20 | - (IBAction)addLevel:(NSButton *)sender; 21 | - (IBAction)minusLevel:(NSButton *)sender; 22 | - (IBAction)deleteWord:(NSButton *)sender; 23 | - (IBAction)talkClick:(NSButton *)sender; 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /Classes/MainViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // MainViewController.h 3 | // MKDic 4 | // 5 | // Created by stm on 11-6-16. 6 | // Copyright 2011 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "CustomViewControllerProtocol.h" 11 | 12 | @interface MainViewController : NSViewController { 13 | IBOutlet NSSegmentedControl *segmentedControl; 14 | IBOutlet NSSegmentedControl *undoSegmentControl; 15 | 16 | NSArray *viewControllerArray; 17 | NSViewController *currentViewController; 18 | } 19 | 20 | - (IBAction)segmentClick:(NSSegmentedControl *)sender; 21 | - (IBAction)fontChangeClick:(NSSegmentedControl *)sender; 22 | 23 | - (IBAction)undoClick:(NSSegmentedControl *)sender; 24 | 25 | - (IBAction)supportClick:(id)sender; 26 | @end 27 | -------------------------------------------------------------------------------- /Classes/WordsViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // WordsViewController.h 3 | // MKDic 4 | // 5 | // Created by stm on 11-6-16. 6 | // Copyright 2011 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "CustomViewControllerProtocol.h" 11 | #import "MKServiceManager.h" 12 | #import "CutomerTextView.h" 13 | 14 | @interface WordsViewController : NSViewController { 16 | @public 17 | IBOutlet NSSearchField *searchField; 18 | IBOutlet NSTextView *toTextView; 19 | 20 | NSMutableArray *translates; //存储所有已经翻译过的 21 | NSInteger displayIndex; //在undo或redo的时候指向translates的编号 22 | } 23 | 24 | - (IBAction)translateBegin:(NSButton *)sender; 25 | - (IBAction)talkClick:(NSButton *)sender; 26 | - (IBAction)addNewWord:(NSButton *)sender; 27 | 28 | - (void)undoAction; 29 | - (void)redoAction; 30 | @end 31 | -------------------------------------------------------------------------------- /Classes/MKDicAppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // MKDicAppDelegate.m 3 | // MKDic 4 | // 5 | // Created by stm on 11-6-16. 6 | // Copyright 2011 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import "MKDicAppDelegate.h" 10 | #import "MainViewController.h" 11 | #import "GeneralManager.h" 12 | 13 | @implementation MKDicAppDelegate 14 | @synthesize window; 15 | 16 | - (void)applicationDidFinishLaunching:(NSNotification *)aNotification 17 | { 18 | 19 | mainViewController=[[MainViewController alloc] initWithNibName:@"MainViewController" bundle:nil]; 20 | [self.window.contentView addSubview:mainViewController.view]; 21 | 22 | [NSApp setServicesProvider:mainViewController]; 23 | } 24 | 25 | - (BOOL)applicationShouldHandleReopen:(NSApplication *)theApplication hasVisibleWindows:(BOOL)flag{ 26 | if (!flag) { 27 | [window makeKeyAndOrderFront:self]; 28 | } 29 | return YES; 30 | } 31 | 32 | - (void)dealloc{ 33 | [mainViewController release]; 34 | [GeneralManager end]; 35 | [super dealloc]; 36 | } 37 | 38 | @end 39 | -------------------------------------------------------------------------------- /Classes/MKWebService_1.1.0/MKWebService.h: -------------------------------------------------------------------------------- 1 | // 2 | // MKWebService.h 3 | // MKNetSaveCard 4 | // 5 | // Created by tanhao on 11-8-3. 6 | // Copyright 2011 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @protocol MKWebServiceDelegate; 12 | @interface MKWebService : NSObject { 13 | id _delegate; 14 | NSURL *_url; 15 | 16 | @private 17 | NSURLConnection *_con; 18 | NSMutableData *_data; 19 | } 20 | @property (nonatomic, assign) id delegate; 21 | @property (nonatomic, retain) NSURL *url; 22 | 23 | /***上传***/ 24 | - (void)uploadDic:(NSDictionary *)dic; 25 | /***下载***/ 26 | - (void)downloadBlob; 27 | 28 | @end 29 | 30 | @protocol MKWebServiceDelegate 31 | 32 | - (void)webServiceBegin:(MKWebService *)webService; 33 | - (void)webServiceFinish:(MKWebService *)webService didReceiveData:(NSData *)data; 34 | - (void)webServiceFail:(MKWebService *)webService didFailWithError:(NSError *)error; 35 | 36 | @end -------------------------------------------------------------------------------- /Classes/WordNoteDao.h: -------------------------------------------------------------------------------- 1 | // 2 | // WordNoteDao.h 3 | // MKDic 4 | // 5 | // Created by 谭 颢 on 11-6-20. 6 | // Copyright 2011 天府学院. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "WordNote.h" 11 | //#import "/usr/include/sqlite3.h" 12 | #import "sqlite3.h" 13 | 14 | #define kFileName @"data.sqlite3" 15 | 16 | #define kSelectExists @"select count(*) from sqlite_master where type='table' and name='WORDS';" 17 | #define kCreateSql @"CREATE TABLE IF NOT EXISTS WORDS(WORD TEXT PRIMARY KEY,TRANSLATION TEXT,STUDYLEVEL INTEGER);" 18 | #define kSelectAllSql @"SELECT * FROM WORDS" 19 | #define kInsertObjSql "INSERT OR REPLACE INTO WORDS (WORD,TRANSLATION,STUDYLEVEL) VALUES (?,?,?);" 20 | #define kDeleteObjSql @"Delete From WORDS where WORD=" 21 | 22 | @interface WordNoteDao : NSObject { 23 | sqlite3 *database; 24 | } 25 | + (id)shareDao; 26 | + (void)end; 27 | 28 | - (BOOL)createTable; 29 | - (NSArray *)selectAll; 30 | - (BOOL)insertWordNote:(WordNote *)aWordNote; 31 | - (BOOL)deleteWordNote:(NSString *)aWord; 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /Classes/SentenceViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // SentenceViewController.h 3 | // MKDic 4 | // 5 | // Created by stm on 11-6-16. 6 | // Copyright 2011 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "CustomViewControllerProtocol.h" 11 | #import "CutomerTextView.h" 12 | #import "MKServiceManager.h" 13 | 14 | @interface SentenceViewController : NSViewController { 16 | @public 17 | IBOutlet NSPopUpButton *fromPopUpButton; 18 | IBOutlet NSPopUpButton *toPopUpButton; 19 | 20 | IBOutlet CutomerTextView *fromTextView; 21 | IBOutlet NSTextView *toTextView; 22 | 23 | NSString *fromLanguage; 24 | NSString *toLanguage; 25 | 26 | NSMutableArray *translates; //存储所有已经翻译过的 27 | NSInteger displayIndex; //在undo或redo的时候指向translates的编号 28 | } 29 | 30 | - (IBAction)buttonChange:(NSPopUpButton *)sender; 31 | - (IBAction)translateBegin:(NSButton *)sender; 32 | - (IBAction)changeClick:(NSButton *)sender; 33 | - (IBAction)talkClick:(NSButton *)sender; 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /Classes/MKWebService_1.1.0/MKServiceManager.h: -------------------------------------------------------------------------------- 1 | // 2 | // MKServiceManager.h 3 | // MKNetSaveCard 4 | // 5 | // Created by tanhao on 11-8-15. 6 | // Copyright 2011年 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "MKWebService.h" 11 | 12 | @protocol MKServiceManagerDelegate; 13 | @interface MKServiceManager : NSObject{ 14 | NSMutableArray *delegates; 15 | NSMutableArray *downloaders; 16 | NSMutableArray *contexts; 17 | } 18 | 19 | + (id)sharedManager; 20 | 21 | - (void)uploadWithURL:(NSURL *)url delegate:(id)delegate postDic:(NSDictionary *)dic context:(id)context; 22 | - (void)downloadWithURL:(NSURL *)url delegate:(id)delegate context:(id)context; 23 | - (void)cancelForDelegate:(id)delegate; 24 | 25 | @end 26 | 27 | 28 | @protocol MKServiceManagerDelegate 29 | 30 | - (void)serviceFinish:(MKServiceManager *)webService didReceiveData:(NSData *)data context:(id)context; 31 | - (void)servicFail:(MKServiceManager *)webService didFailWithError:(NSError *)error context:(id)context; 32 | 33 | @end -------------------------------------------------------------------------------- /Classes/TouchJSON/Extensions/NSCharacterSet_Extensions.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSCharacterSet_Extensions.h 3 | // TouchJSON 4 | // 5 | // Created by Jonathan Wight on 12/08/2005. 6 | // Copyright (c) 2005 Jonathan Wight 7 | // 8 | // Permission is hereby granted, free of charge, to any person 9 | // obtaining a copy of this software and associated documentation 10 | // files (the "Software"), to deal in the Software without 11 | // restriction, including without limitation the rights to use, 12 | // copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the 14 | // Software is furnished to do so, subject to the following 15 | // conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 22 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 24 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 25 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 26 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 27 | // OTHER DEALINGS IN THE SOFTWARE. 28 | // 29 | 30 | #import 31 | 32 | @interface NSCharacterSet (NSCharacterSet_Extensions) 33 | 34 | + (NSCharacterSet *)linebreaksCharacterSet; 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /Classes/TouchJSON/Extensions/NSDictionary_JSONExtensions.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSDictionary_JSONExtensions.h 3 | // TouchJSON 4 | // 5 | // Created by Jonathan Wight on 04/17/08. 6 | // Copyright (c) 2008 Jonathan Wight 7 | // 8 | // Permission is hereby granted, free of charge, to any person 9 | // obtaining a copy of this software and associated documentation 10 | // files (the "Software"), to deal in the Software without 11 | // restriction, including without limitation the rights to use, 12 | // copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the 14 | // Software is furnished to do so, subject to the following 15 | // conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 22 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 24 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 25 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 26 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 27 | // OTHER DEALINGS IN THE SOFTWARE. 28 | // 29 | 30 | #import 31 | 32 | @interface NSDictionary (NSDictionary_JSONExtensions) 33 | 34 | + (id)dictionaryWithJSONData:(NSData *)inData error:(NSError **)outError; 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /Classes/CutomerTextView.m: -------------------------------------------------------------------------------- 1 | // 2 | // CutomerTextView.m 3 | // MKDic 4 | // 5 | // Created by stm on 11-6-16. 6 | // Copyright 2011 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import "CutomerTextView.h" 10 | 11 | 12 | @implementation CutomerTextView 13 | @synthesize delegate; 14 | 15 | - (void)insertNewline:(id)sender{ 16 | //[super insertNewline:sender]; 17 | if ([delegate respondsToSelector:@selector(enterClick:)]) { 18 | [delegate enterClick:sender]; 19 | } 20 | } 21 | 22 | - (id)validRequestorForSendType:(NSString *)sendType returnType:(NSString *)returnType{ 23 | id returnObj=[super validRequestorForSendType:sendType returnType:returnType]; 24 | return returnObj; 25 | } 26 | 27 | - (BOOL)validateUserInterfaceItem:(id < NSValidatedUserInterfaceItem >)anItem{ 28 | NSMenuItem *menuItem=(NSMenuItem *)anItem; 29 | if ([[menuItem title] isEqual:@"Search in Spotlight"]) { 30 | if ([delegate respondsToSelector:@selector(rightMenuItemClick:)]) { 31 | [menuItem setTitle:@"查询此单词"]; 32 | [menuItem setTarget:self]; 33 | [menuItem setAction:@selector(menuItemClick)]; 34 | } 35 | } 36 | return [super validateUserInterfaceItem:anItem]; 37 | } 38 | 39 | - (void)menuItemClick{ 40 | if ([delegate respondsToSelector:@selector(rightMenuItemClick:)]) { 41 | NSArray *ranges=[self selectedRanges]; 42 | if ([ranges count]>0) { 43 | NSValue *rangeVal=(NSValue *)[ranges objectAtIndex:0]; 44 | NSRange range=[rangeVal rangeValue]; 45 | NSString *rangeString=[[self string] substringWithRange:range]; 46 | [delegate rightMenuItemClick:rangeString]; 47 | } 48 | } 49 | } 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /Classes/TouchJSON/Extensions/CDataScanner_Extensions.h: -------------------------------------------------------------------------------- 1 | // 2 | // CDataScanner_Extensions.h 3 | // TouchJSON 4 | // 5 | // Created by Jonathan Wight on 12/08/2005. 6 | // Copyright (c) 2005 Jonathan Wight 7 | // 8 | // Permission is hereby granted, free of charge, to any person 9 | // obtaining a copy of this software and associated documentation 10 | // files (the "Software"), to deal in the Software without 11 | // restriction, including without limitation the rights to use, 12 | // copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the 14 | // Software is furnished to do so, subject to the following 15 | // conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 22 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 24 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 25 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 26 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 27 | // OTHER DEALINGS IN THE SOFTWARE. 28 | // 29 | 30 | #import "CDataScanner.h" 31 | 32 | @interface CDataScanner (CDataScanner_Extensions) 33 | 34 | - (BOOL)scanCStyleComment:(NSString **)outComment; 35 | - (BOOL)scanCPlusPlusStyleComment:(NSString **)outComment; 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /Classes/TouchJSON/Extensions/NSDictionary_JSONExtensions.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSDictionary_JSONExtensions.m 3 | // TouchJSON 4 | // 5 | // Created by Jonathan Wight on 04/17/08. 6 | // Copyright (c) 2008 Jonathan Wight 7 | // 8 | // Permission is hereby granted, free of charge, to any person 9 | // obtaining a copy of this software and associated documentation 10 | // files (the "Software"), to deal in the Software without 11 | // restriction, including without limitation the rights to use, 12 | // copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the 14 | // Software is furnished to do so, subject to the following 15 | // conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 22 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 24 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 25 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 26 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 27 | // OTHER DEALINGS IN THE SOFTWARE. 28 | // 29 | 30 | #import "NSDictionary_JSONExtensions.h" 31 | 32 | #import "CJSONDeserializer.h" 33 | 34 | @implementation NSDictionary (NSDictionary_JSONExtensions) 35 | 36 | + (id)dictionaryWithJSONData:(NSData *)inData error:(NSError **)outError 37 | { 38 | return([[CJSONDeserializer deserializer] deserialize:inData error:outError]); 39 | } 40 | 41 | @end 42 | -------------------------------------------------------------------------------- /Classes/GeneralManager.m: -------------------------------------------------------------------------------- 1 | // 2 | // GeneralManager.m 3 | // MKDic 4 | // 5 | // Created by stm on 11-6-16. 6 | // Copyright 2011 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import "GeneralManager.h" 10 | 11 | static GeneralManager *generalManager; 12 | @implementation GeneralManager 13 | 14 | + (id)shareManager{ 15 | if (generalManager==nil) { 16 | generalManager=[[GeneralManager alloc] init]; 17 | } 18 | return generalManager; 19 | } 20 | 21 | + (void)end{ 22 | if (generalManager!=nil) { 23 | [generalManager release]; 24 | generalManager=nil; 25 | } 26 | } 27 | 28 | - (void)dealloc{ 29 | [speechSynth release]; 30 | [super dealloc]; 31 | } 32 | 33 | #pragma mark - 34 | #pragma mark CustomFunc 35 | - (void)speakWithText:(NSString *)aText{ 36 | if(!speechSynth) speechSynth = [[NSSpeechSynthesizer alloc] initWithVoice:nil]; 37 | [speechSynth startSpeakingString:aText]; 38 | } 39 | 40 | - (void)stopSpeak{ 41 | [speechSynth stopSpeaking]; 42 | } 43 | 44 | - (NSString *)stringFromEscapes:(NSString *)aString{ 45 | NSMutableString *resultString=[NSMutableString stringWithString:aString]; 46 | NSString* escapes[][2]={ 47 | {@"ə",@"ə"}, 48 | {@"ɔ",@"ɔ"}, 49 | {@"ʌ",@"ʌ"}, 50 | {@"æ",@"æ"}, 51 | {@"ɑ",@"ɑ"}, 52 | {@"ɛ",@"ɛ"}, 53 | {@"θ",@"θ"}, 54 | {@"ŋ",@"ŋ"}, 55 | {@"ʃ",@"ʃ"}, 56 | {@"ð",@"ð"}, 57 | {@"ʒ",@"ʒ"}, 58 | {@"ʊ",@"ʊ"}, 59 | {@"<",@"<"}, 60 | {@">",@">"}, 61 | }; 62 | for (int i=0; i 31 | 32 | @interface NSScanner (NSScanner_Extensions) 33 | 34 | - (NSString *)remainingString; 35 | 36 | - (unichar)currentCharacter; 37 | - (unichar)scanCharacter; 38 | - (BOOL)scanCharacter:(unichar)inCharacter; 39 | - (void)backtrack:(unsigned)inCount; 40 | 41 | - (BOOL)scanCStyleComment:(NSString **)outComment; 42 | - (BOOL)scanCPlusPlusStyleComment:(NSString **)outComment; 43 | 44 | @end 45 | -------------------------------------------------------------------------------- /Classes/TouchJSON/JSON/CJSONSerializer.h: -------------------------------------------------------------------------------- 1 | // 2 | // CJSONSerializer.h 3 | // TouchJSON 4 | // 5 | // Created by Jonathan Wight on 12/07/2005. 6 | // Copyright (c) 2005 Jonathan Wight 7 | // 8 | // Permission is hereby granted, free of charge, to any person 9 | // obtaining a copy of this software and associated documentation 10 | // files (the "Software"), to deal in the Software without 11 | // restriction, including without limitation the rights to use, 12 | // copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the 14 | // Software is furnished to do so, subject to the following 15 | // conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 22 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 24 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 25 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 26 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 27 | // OTHER DEALINGS IN THE SOFTWARE. 28 | // 29 | 30 | #import 31 | 32 | @interface CJSONSerializer : NSObject { 33 | } 34 | 35 | + (id)serializer; 36 | 37 | - (NSString *)serializeObject:(id)inObject; 38 | 39 | - (NSString *)serializeNull:(NSNull *)inNull; 40 | - (NSString *)serializeNumber:(NSNumber *)inNumber; 41 | - (NSString *)serializeString:(NSString *)inString; 42 | - (NSString *)serializeArray:(NSArray *)inArray; 43 | - (NSString *)serializeDictionary:(NSDictionary *)inDictionary; 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /Credits.rtf: -------------------------------------------------------------------------------- 1 | {\rtf1\ansi\ansicpg936\cocoartf1138\cocoasubrtf320 2 | {\fonttbl\f0\fnil\fcharset134 STKaiti;\f1\fnil\fcharset134 SIL-Kai-Reg-Jian;} 3 | {\colortbl;\red255\green255\blue255;\red0\green128\blue128;\red255\green39\blue18;} 4 | \vieww10800\viewh7200\viewkind0 5 | \deftab720 6 | \pard\pardeftab720 7 | 8 | \f0\fs28 \cf2 \'b1\'be\'c8\'ed\'bc\'fe\'d3\'c9\'d7\'f7\'d5\'df\'d1\'a7\'cf\'b0\'bc\'b0\'bd\'bb\'c1\'f7\'cb\'f9\'d3\'c3\'a3\'ac\'c8\'ce\'ba\'ce\'d7\'e9\'d6\'af\'ba\'cd\'b8\'f6\'c8\'cb\'b2\'bb\'b5\'c3\'d3\'c3\'d7\'f7\'c9\'cc\'d2\'b5\'d3\'c3\'cd\'be\'a3\'ac\'d3\'c9\'b4\'cb\'b3\'f6\'cf\'d6\'b5\'c4\'b7\'a8\'c2\'c9\'ba\'f3\'b9\'fb\'d7\'d4\'b8\'ba\'a3\'a1\ 9 | \'bb\'b6\'d3\'ad\'c4\'e3\'cf\'f2\'d7\'f7\'d5\'df\'cc\'e1\'b3\'f6\'b1\'a6\'b9\'f3\'b5\'c4\'bd\'a8\'d2\'e9\'ba\'cd\'d2\'e2\'bc\'fb\'a3\'ba\'cc\'b7\'f2\'ab\'a3\'a8 10 | \f1 http://www.tanhao.me\'a3\'a9.\ 11 | \ 12 | \cf3 3.0 \'b8\'fc\'d0\'c2\'c4\'da\'c8\'dd\'a3\'ba\ 13 | \ 14 | 1.\'d0\'de\'d5\'fd\'c1\'cb\'d2\'f2\'ce\'aa\'b9\'c8\'b8\'e8\'b7\'ad\'d2\'ebAPI\'cd\'a3\'d3\'c3\'b5\'bc\'d6\'c2\'b7\'ad\'d2\'eb\'b2\'bb\'c4\'dc\'ca\'b9\'d3\'c3\'b5\'c4\'ce\'ca\'cc\'e2\'a3\'bb\ 15 | 2.\'bd\'ab\'b7\'ad\'d2\'eb\'d2\'fd\'c7\'e6\'d0\'de\'b8\'c4\'ce\'aa\'ce\'a2\'c8\'ed\'b5\'c4API\'a3\'ac\'b7\'ad\'d2\'eb\'cb\'d9\'b6\'c8\'b8\'fc\'bf\'ec\'bd\'dd\'a3\'bb\ 16 | 3.\'d4\'f6\'bc\'d3\'c1\'cb\'cf\'b5\'cd\'b3\'b7\'fe\'ce\'f1\'a3\'ac\'d4\'da\'c8\'ce\'ba\'ce\'b5\'d8\'b7\'bd\'d3\'d2\'bc\'fc\'bc\'c8\'bf\'c9\'b2\'e9\'d1\'af\'b7\'ad\'d2\'eb(\'d0\'e8\'d2\'aa\'d6\'d8\'c6\'f4\'c9\'fa\'d0\'a7)\'a3\'bb\cf2 \ 17 | \ 18 | 2.0 \'b8\'fc\'d0\'c2\'c4\'da\'c8\'dd\'a3\'ba\ 19 | \ 20 | 1.\'bc\'d3\'c8\'eb\'c1\'cb\'d1\'a7\'cf\'b0\'b9\'a6\'c4\'dc\'a3\'bb\ 21 | 2.\'bc\'d3\'c8\'eb\'c9\'fa\'b4\'ca\'b1\'be\'b5\'c4\'b9\'a6\'c4\'dc\'a3\'bb\ 22 | 3.\'d4\'da\'b2\'e9\'d1\'af\'bd\'e1\'b9\'fb\'d6\'d0\'b6\'fe\'b4\'ce\'b2\'e9\'d1\'af\'a3\'bb\ 23 | 4.\'d4\'da\'b2\'e9\'d1\'af\'b9\'fd\'b3\'cc\'d6\'d0\'c7\'b0\'bd\'f8\'ba\'f3\'cd\'cb\'b5\'c4\'b9\'a6\'c4\'dc\'a3\'bb} -------------------------------------------------------------------------------- /Classes/TouchJSON/JSON/CJSONScanner.h: -------------------------------------------------------------------------------- 1 | // 2 | // CJSONScanner.h 3 | // TouchJSON 4 | // 5 | // Created by Jonathan Wight on 12/07/2005. 6 | // Copyright (c) 2005 Jonathan Wight 7 | // 8 | // Permission is hereby granted, free of charge, to any person 9 | // obtaining a copy of this software and associated documentation 10 | // files (the "Software"), to deal in the Software without 11 | // restriction, including without limitation the rights to use, 12 | // copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the 14 | // Software is furnished to do so, subject to the following 15 | // conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 22 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 24 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 25 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 26 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 27 | // OTHER DEALINGS IN THE SOFTWARE. 28 | // 29 | 30 | #import "CDataScanner.h" 31 | 32 | @interface CJSONScanner : CDataScanner { 33 | } 34 | 35 | - (BOOL)scanJSONObject:(id *)outObject error:(NSError **)outError; 36 | - (BOOL)scanJSONDictionary:(NSDictionary **)outDictionary error:(NSError **)outError; 37 | - (BOOL)scanJSONArray:(NSArray **)outArray error:(NSError **)outError; 38 | - (BOOL)scanJSONStringConstant:(NSString **)outStringConstant error:(NSError **)outError; 39 | - (BOOL)scanJSONNumberConstant:(NSNumber **)outNumberConstant error:(NSError **)outError; 40 | 41 | @end 42 | 43 | extern NSString *const kJSONScannerErrorDomain /* = @"CJSONScannerErrorDomain" */; 44 | -------------------------------------------------------------------------------- /Classes/TouchJSON/Extensions/NSCharacterSet_Extensions.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSCharacterSet_Extensions.m 3 | // TouchJSON 4 | // 5 | // Created by Jonathan Wight on 12/08/2005. 6 | // Copyright (c) 2005 Jonathan Wight 7 | // 8 | // Permission is hereby granted, free of charge, to any person 9 | // obtaining a copy of this software and associated documentation 10 | // files (the "Software"), to deal in the Software without 11 | // restriction, including without limitation the rights to use, 12 | // copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the 14 | // Software is furnished to do so, subject to the following 15 | // conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 22 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 24 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 25 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 26 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 27 | // OTHER DEALINGS IN THE SOFTWARE. 28 | // 29 | 30 | #import "NSCharacterSet_Extensions.h" 31 | 32 | @implementation NSCharacterSet (NSCharacterSet_Extensions) 33 | 34 | #define LF 0x000a // Line Feed 35 | #define FF 0x000c // Form Feed 36 | #define CR 0x000d // Carriage Return 37 | #define NEL 0x0085 // Next Line 38 | #define LS 0x2028 // Line Separator 39 | #define PS 0x2029 // Paragraph Separator 40 | 41 | + (NSCharacterSet *)linebreaksCharacterSet 42 | { 43 | unichar theCharacters[] = { LF, FF, CR, NEL, LS, PS, }; 44 | 45 | return([NSCharacterSet characterSetWithCharactersInString:[NSString stringWithCharacters:theCharacters length:sizeof(theCharacters) / sizeof(*theCharacters)]]); 46 | } 47 | 48 | @end 49 | -------------------------------------------------------------------------------- /Classes/TouchJSON/JSON/CJSONDeserializer.h: -------------------------------------------------------------------------------- 1 | // 2 | // CJSONDeserializer.h 3 | // TouchJSON 4 | // 5 | // Created by Jonathan Wight on 12/15/2005. 6 | // Copyright (c) 2005 Jonathan Wight 7 | // 8 | // Permission is hereby granted, free of charge, to any person 9 | // obtaining a copy of this software and associated documentation 10 | // files (the "Software"), to deal in the Software without 11 | // restriction, including without limitation the rights to use, 12 | // copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the 14 | // Software is furnished to do so, subject to the following 15 | // conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 22 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 24 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 25 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 26 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 27 | // OTHER DEALINGS IN THE SOFTWARE. 28 | // 29 | 30 | #import 31 | 32 | extern NSString *const kJSONDeserializerErrorDomain /* = @"CJSONDeserializerErrorDomain" */; 33 | 34 | @protocol CDeserializerProtocol 35 | 36 | - (id)deserializeAsDictionary:(NSData *)inData error:(NSError **)outError; 37 | 38 | @end 39 | 40 | #pragma mark - 41 | 42 | @interface CJSONDeserializer : NSObject { 43 | 44 | } 45 | 46 | + (id)deserializer; 47 | 48 | - (id)deserializeAsDictionary:(NSData *)inData error:(NSError **)outError; 49 | 50 | @end 51 | 52 | #pragma mark - 53 | 54 | @interface CJSONDeserializer (CJSONDeserializer_Deprecated) 55 | 56 | /// You should switch to using deserializeAsDictionary:error: instead. 57 | - (id)deserialize:(NSData *)inData error:(NSError **)outError; 58 | 59 | @end 60 | -------------------------------------------------------------------------------- /MKDic-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | 迷你词典 9 | CFBundleIconFile 10 | interact.icns 11 | CFBundleIdentifier 12 | com.yourcompany.minidic 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | 迷你词典 17 | LSBackgroundOnly 18 | NO 19 | CFBundlePackageType 20 | APPL 21 | CFBundleShortVersionString 22 | 3.1 23 | CFBundleSignature 24 | ???? 25 | CFBundleVersion 26 | 1 27 | LSMinimumSystemVersion 28 | ${MACOSX_DEPLOYMENT_TARGET} 29 | NSMainNibFile 30 | MainMenu 31 | NSPrincipalClass 32 | NSApplication 33 | NSServices 34 | 35 | 36 | NSKeyEquivalent 37 | 38 | default 39 | E 40 | 41 | NSMenuItem 42 | 43 | default 44 | 迷你词典 • 翻译选中内容 45 | 46 | NSMessage 47 | srvTranslate 48 | NSPortName 49 | 迷你词典 50 | NSRequiredContext 51 | 52 | NSServiceCategory 53 | public.text 54 | 55 | NSSendTypes 56 | 57 | NSStringPboardType 58 | 59 | 60 | 61 | NSKeyEquivalent 62 | 63 | default 64 | P 65 | 66 | NSMenuItem 67 | 68 | default 69 | 迷你词典 • 查询选中单词 70 | 71 | NSMessage 72 | srvSearch 73 | NSPortName 74 | 迷你词典 75 | NSRequiredContext 76 | 77 | NSServiceCategory 78 | public.text 79 | 80 | NSSendTypes 81 | 82 | NSStringPboardType 83 | 84 | 85 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /Classes/TouchJSON/CDataScanner.h: -------------------------------------------------------------------------------- 1 | // 2 | // CDataScanner.h 3 | // TouchJSON 4 | // 5 | // Created by Jonathan Wight on 04/16/08. 6 | // Copyright (c) 2008 Jonathan Wight 7 | // 8 | // Permission is hereby granted, free of charge, to any person 9 | // obtaining a copy of this software and associated documentation 10 | // files (the "Software"), to deal in the Software without 11 | // restriction, including without limitation the rights to use, 12 | // copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the 14 | // Software is furnished to do so, subject to the following 15 | // conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 22 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 24 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 25 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 26 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 27 | // OTHER DEALINGS IN THE SOFTWARE. 28 | // 29 | 30 | #import 31 | 32 | // NSScanner 33 | 34 | @interface CDataScanner : NSObject { 35 | NSData *data; 36 | 37 | u_int8_t *start; 38 | u_int8_t *end; 39 | u_int8_t *current; 40 | NSUInteger length; 41 | 42 | NSCharacterSet *doubleCharacters; 43 | } 44 | 45 | @property (readwrite, nonatomic, retain) NSData *data; 46 | @property (readwrite, nonatomic, assign) NSUInteger scanLocation; 47 | @property (readonly, nonatomic, assign) BOOL isAtEnd; 48 | 49 | + (id)scannerWithData:(NSData *)inData; 50 | 51 | - (unichar)currentCharacter; 52 | - (unichar)scanCharacter; 53 | - (BOOL)scanCharacter:(unichar)inCharacter; 54 | 55 | - (BOOL)scanUTF8String:(const char *)inString intoString:(NSString **)outValue; 56 | - (BOOL)scanString:(NSString *)inString intoString:(NSString **)outValue; 57 | - (BOOL)scanCharactersFromSet:(NSCharacterSet *)inSet intoString:(NSString **)outValue; // inSet must only contain 7-bit ASCII characters 58 | 59 | - (BOOL)scanUpToString:(NSString *)string intoString:(NSString **)outValue; 60 | - (BOOL)scanUpToCharactersFromSet:(NSCharacterSet *)set intoString:(NSString **)outValue; // inSet must only contain 7-bit ASCII characters 61 | 62 | - (BOOL)scanNumber:(NSNumber **)outValue; 63 | 64 | - (void)skipWhitespace; 65 | 66 | - (NSString *)remainingString; 67 | 68 | @end 69 | -------------------------------------------------------------------------------- /Classes/TouchJSON/JSON/CJSONDeserializer.m: -------------------------------------------------------------------------------- 1 | // 2 | // CJSONDeserializer.m 3 | // TouchJSON 4 | // 5 | // Created by Jonathan Wight on 12/15/2005. 6 | // Copyright (c) 2005 Jonathan Wight 7 | // 8 | // Permission is hereby granted, free of charge, to any person 9 | // obtaining a copy of this software and associated documentation 10 | // files (the "Software"), to deal in the Software without 11 | // restriction, including without limitation the rights to use, 12 | // copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the 14 | // Software is furnished to do so, subject to the following 15 | // conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 22 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 24 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 25 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 26 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 27 | // OTHER DEALINGS IN THE SOFTWARE. 28 | // 29 | 30 | #import "CJSONDeserializer.h" 31 | 32 | #import "CJSONScanner.h" 33 | #import "CDataScanner.h" 34 | 35 | NSString *const kJSONDeserializerErrorDomain = @"CJSONDeserializerErrorDomain"; 36 | 37 | @implementation CJSONDeserializer 38 | 39 | + (id)deserializer 40 | { 41 | return([[[self alloc] init] autorelease]); 42 | } 43 | 44 | - (id)deserializeAsDictionary:(NSData *)inData error:(NSError **)outError; 45 | { 46 | if (inData == NULL || [inData length] == 0) 47 | { 48 | if (outError) 49 | *outError = [NSError errorWithDomain:kJSONDeserializerErrorDomain code:-1 userInfo:NULL]; 50 | 51 | return(NULL); 52 | } 53 | CJSONScanner *theScanner = [CJSONScanner scannerWithData:inData]; 54 | NSDictionary *theDictionary = NULL; 55 | if ([theScanner scanJSONDictionary:&theDictionary error:outError] == YES) 56 | return(theDictionary); 57 | else 58 | return(NULL); 59 | } 60 | 61 | @end 62 | 63 | #pragma mark - 64 | 65 | @implementation CJSONDeserializer (CJSONDeserializer_Deprecated) 66 | 67 | - (id)deserialize:(NSData *)inData error:(NSError **)outError 68 | { 69 | if (inData == NULL || [inData length] == 0) 70 | { 71 | if (outError) 72 | *outError = [NSError errorWithDomain:kJSONDeserializerErrorDomain code:-1 userInfo:NULL]; 73 | 74 | return(NULL); 75 | } 76 | CJSONScanner *theScanner = [CJSONScanner scannerWithData:inData]; 77 | id theObject = NULL; 78 | if ([theScanner scanJSONObject:&theObject error:outError] == YES) 79 | return(theObject); 80 | else 81 | return(NULL); 82 | } 83 | 84 | @end 85 | -------------------------------------------------------------------------------- /Classes/TouchJSON/Extensions/CDataScanner_Extensions.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSScanner_Extensions.m 3 | // TouchJSON 4 | // 5 | // Created by Jonathan Wight on 12/08/2005. 6 | // Copyright (c) 2005 Jonathan Wight 7 | // 8 | // Permission is hereby granted, free of charge, to any person 9 | // obtaining a copy of this software and associated documentation 10 | // files (the "Software"), to deal in the Software without 11 | // restriction, including without limitation the rights to use, 12 | // copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the 14 | // Software is furnished to do so, subject to the following 15 | // conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 22 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 24 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 25 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 26 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 27 | // OTHER DEALINGS IN THE SOFTWARE. 28 | // 29 | 30 | #import "CDataScanner_Extensions.h" 31 | 32 | #import "NSCharacterSet_Extensions.h" 33 | 34 | @implementation CDataScanner (CDataScanner_Extensions) 35 | 36 | - (BOOL)scanCStyleComment:(NSString **)outComment 37 | { 38 | if ([self scanString:@"/*" intoString:NULL] == YES) 39 | { 40 | NSString *theComment = NULL; 41 | if ([self scanUpToString:@"*/" intoString:&theComment] == NO) 42 | [NSException raise:NSGenericException format:@"Started to scan a C style comment but it wasn't terminated."]; 43 | 44 | if ([theComment rangeOfString:@"/*"].location != NSNotFound) 45 | [NSException raise:NSGenericException format:@"C style comments should not be nested."]; 46 | 47 | if ([self scanString:@"*/" intoString:NULL] == NO) 48 | [NSException raise:NSGenericException format:@"C style comment did not end correctly."]; 49 | 50 | if (outComment != NULL) 51 | *outComment = theComment; 52 | 53 | return(YES); 54 | } 55 | else 56 | { 57 | return(NO); 58 | } 59 | } 60 | 61 | - (BOOL)scanCPlusPlusStyleComment:(NSString **)outComment 62 | { 63 | if ([self scanString:@"//" intoString:NULL] == YES) 64 | { 65 | NSString *theComment = NULL; 66 | [self scanUpToCharactersFromSet:[NSCharacterSet linebreaksCharacterSet] intoString:&theComment]; 67 | [self scanCharactersFromSet:[NSCharacterSet linebreaksCharacterSet] intoString:NULL]; 68 | 69 | if (outComment != NULL) 70 | *outComment = theComment; 71 | 72 | return(YES); 73 | } 74 | else 75 | { 76 | return(NO); 77 | } 78 | } 79 | 80 | @end 81 | -------------------------------------------------------------------------------- /MKDic.xcodeproj/xcuserdata/mac.xcuserdatad/xcschemes/MKDic.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 14 | 20 | 21 | 22 | 23 | 24 | 29 | 30 | 31 | 32 | 38 | 39 | 40 | 41 | 49 | 50 | 56 | 57 | 58 | 59 | 60 | 61 | 67 | 68 | 74 | 75 | 76 | 77 | 79 | 80 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /Classes/TouchJSON/Extensions/NSScanner_Extensions.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSScanner_Extensions.m 3 | // CocoaJSON 4 | // 5 | // Created by Jonathan Wight on 12/08/2005. 6 | // Copyright (c) 2005 Jonathan Wight 7 | // 8 | // Permission is hereby granted, free of charge, to any person 9 | // obtaining a copy of this software and associated documentation 10 | // files (the "Software"), to deal in the Software without 11 | // restriction, including without limitation the rights to use, 12 | // copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the 14 | // Software is furnished to do so, subject to the following 15 | // conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 22 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 24 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 25 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 26 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 27 | // OTHER DEALINGS IN THE SOFTWARE. 28 | // 29 | 30 | #import "NSScanner_Extensions.h" 31 | 32 | #import "NSCharacterSet_Extensions.h" 33 | 34 | @implementation NSScanner (NSScanner_Extensions) 35 | 36 | - (NSString *)remainingString 37 | { 38 | return([[self string] substringFromIndex:[self scanLocation]]); 39 | } 40 | 41 | - (unichar)currentCharacter 42 | { 43 | return([[self string] characterAtIndex:[self scanLocation]]); 44 | } 45 | 46 | - (unichar)scanCharacter 47 | { 48 | unsigned theScanLocation = [self scanLocation]; 49 | unichar theCharacter = [[self string] characterAtIndex:theScanLocation]; 50 | [self setScanLocation:theScanLocation + 1]; 51 | return(theCharacter); 52 | } 53 | 54 | - (BOOL)scanCharacter:(unichar)inCharacter 55 | { 56 | unsigned theScanLocation = [self scanLocation]; 57 | if ([[self string] characterAtIndex:theScanLocation] == inCharacter) 58 | { 59 | [self setScanLocation:theScanLocation + 1]; 60 | return(YES); 61 | } 62 | else 63 | return(NO); 64 | } 65 | 66 | - (void)backtrack:(unsigned)inCount 67 | { 68 | unsigned theScanLocation = [self scanLocation]; 69 | if (inCount > theScanLocation) 70 | [NSException raise:NSGenericException format:@"Backtracked too far."]; 71 | [self setScanLocation:theScanLocation - inCount]; 72 | } 73 | 74 | - (BOOL)scanCStyleComment:(NSString **)outComment 75 | { 76 | if ([self scanString:@"/*" intoString:NULL] == YES) 77 | { 78 | NSString *theComment = NULL; 79 | if ([self scanUpToString:@"*/" intoString:&theComment] == NO) 80 | [NSException raise:NSGenericException format:@"Started to scan a C style comment but it wasn't terminated."]; 81 | 82 | if ([theComment rangeOfString:@"/*"].location != NSNotFound) 83 | [NSException raise:NSGenericException format:@"C style comments should not be nested."]; 84 | 85 | if ([self scanString:@"*/" intoString:NULL] == NO) 86 | [NSException raise:NSGenericException format:@"C style comment did not end correctly."]; 87 | 88 | if (outComment != NULL) 89 | *outComment = theComment; 90 | 91 | return(YES); 92 | } 93 | else 94 | { 95 | return(NO); 96 | } 97 | } 98 | 99 | - (BOOL)scanCPlusPlusStyleComment:(NSString **)outComment 100 | { 101 | if ([self scanString:@"//" intoString:NULL] == YES) 102 | { 103 | NSString *theComment = NULL; 104 | [self scanUpToCharactersFromSet:[NSCharacterSet linebreaksCharacterSet] intoString:&theComment]; 105 | [self scanCharactersFromSet:[NSCharacterSet linebreaksCharacterSet] intoString:NULL]; 106 | 107 | if (outComment != NULL) 108 | *outComment = theComment; 109 | 110 | return(YES); 111 | } 112 | else 113 | { 114 | return(NO); 115 | } 116 | } 117 | 118 | @end 119 | -------------------------------------------------------------------------------- /Classes/WordNoteDao.m: -------------------------------------------------------------------------------- 1 | // 2 | // WordNoteDao.m 3 | // MKDic 4 | // 5 | // Created by 谭 颢 on 11-6-20. 6 | // Copyright 2011 天府学院. All rights reserved. 7 | // 8 | 9 | #import "WordNoteDao.h" 10 | @interface WordNoteDao() 11 | - (BOOL)tableExists; 12 | - (NSString *)dataFilePath; 13 | @end 14 | 15 | static WordNoteDao *wordNoteDao=nil; 16 | 17 | @implementation WordNoteDao 18 | 19 | + (id)shareDao{ 20 | if (wordNoteDao==nil) { 21 | wordNoteDao=[[WordNoteDao alloc] init]; 22 | } 23 | return wordNoteDao; 24 | } 25 | 26 | + (void)end{ 27 | if (wordNoteDao!=nil) { 28 | [wordNoteDao release]; 29 | wordNoteDao=nil; 30 | } 31 | } 32 | 33 | - (id)init{ 34 | self=[super init]; 35 | if (self) { 36 | //打开数据库 37 | if (sqlite3_open([[self dataFilePath] UTF8String], &database)!=SQLITE_OK) { 38 | sqlite3_close(database); 39 | NSAssert(0,@"Faild to open database"); 40 | } 41 | //建表 42 | if (![self tableExists]) { 43 | [self createTable]; 44 | } 45 | } 46 | return self; 47 | } 48 | 49 | - (void)dealloc{ 50 | sqlite3_close(database); 51 | [super dealloc]; 52 | } 53 | 54 | #pragma mark - 55 | #pragma mark CustomerFunc 56 | 57 | - (NSString *)dataFilePath{ 58 | NSArray *paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 59 | NSString *documentDirectory=[paths objectAtIndex:0]; 60 | NSString *miniDirectory=[documentDirectory stringByAppendingPathComponent:@"MiniDic_Data"]; 61 | NSLog(@"%@",miniDirectory); 62 | if (![[NSFileManager defaultManager] isWritableFileAtPath:miniDirectory]) { 63 | NSError *error; 64 | BOOL createDir=[[NSFileManager defaultManager] createDirectoryAtPath:miniDirectory 65 | withIntermediateDirectories:YES 66 | attributes:nil 67 | error:&error]; 68 | NSAssert(createDir,@"Create directory error:%@",error); 69 | } 70 | return [miniDirectory stringByAppendingPathComponent:kFileName]; 71 | } 72 | 73 | //判断表是否存在 74 | - (BOOL)tableExists{ 75 | int number=0; 76 | NSString *query=kSelectExists; 77 | sqlite3_stmt *statement; 78 | if (sqlite3_prepare(database, [query UTF8String], -1, &statement, nil)==SQLITE_OK) { 79 | while (sqlite3_step(statement)==SQLITE_ROW) { 80 | number=sqlite3_column_int(statement, 0); 81 | } 82 | } 83 | NSLog(@"%d",number); 84 | 85 | return number==0?NO:YES; 86 | } 87 | 88 | - (BOOL)createTable{ 89 | char *errorMsg; 90 | NSString *createSQL=kCreateSql; 91 | if (sqlite3_exec(database, [createSQL UTF8String], NULL, NULL, &errorMsg)!=SQLITE_OK) { 92 | sqlite3_close(database); 93 | NSAssert(0,@"Error creating table:%s",errorMsg); 94 | return NO; 95 | } 96 | return YES; 97 | } 98 | 99 | - (NSArray *)selectAll{ 100 | NSMutableArray *resultArray=[[[NSMutableArray alloc] init] autorelease]; 101 | NSString *query=kSelectAllSql; 102 | sqlite3_stmt *statement; 103 | if (sqlite3_prepare(database, [query UTF8String], -1, &statement, nil)==SQLITE_OK) { 104 | while (sqlite3_step(statement)==SQLITE_ROW) { 105 | char *word=(char *)sqlite3_column_text(statement, 0); 106 | char *translate=(char *)sqlite3_column_text(statement, 1); 107 | int level=sqlite3_column_int(statement, 2); 108 | 109 | WordNote *wordNote=[[WordNote alloc] init]; 110 | wordNote.word=[NSString stringWithUTF8String:word]; 111 | wordNote.translate=[NSString stringWithUTF8String:translate]; 112 | wordNote.level=level; 113 | [resultArray addObject:wordNote]; 114 | [wordNote release]; 115 | } 116 | sqlite3_finalize(statement); 117 | } 118 | return resultArray; 119 | } 120 | 121 | - (BOOL)insertWordNote:(WordNote *)aWordNote{ 122 | //char *errorMsg; 123 | char *update=kInsertObjSql; 124 | sqlite3_stmt *stmt; 125 | if (sqlite3_prepare(database, update, -1, &stmt, nil)==SQLITE_OK) { 126 | __strong const char *word=[aWordNote.word UTF8String]; 127 | __strong const char *translate=[aWordNote.translate UTF8String]; 128 | int level=aWordNote.level; 129 | 130 | sqlite3_bind_text(stmt, 1, word, -1, NULL); 131 | sqlite3_bind_text(stmt, 2, translate, -1, NULL); 132 | sqlite3_bind_int(stmt, 3, level); 133 | } 134 | if (sqlite3_step(stmt)!=SQLITE_DONE) { 135 | //NSAssert(0,@"Error updating table:%s",errorMsg); 136 | sqlite3_finalize(stmt); 137 | return NO; 138 | } 139 | sqlite3_finalize(stmt); 140 | return YES; 141 | } 142 | 143 | - (BOOL)deleteWordNote:(NSString *)aWord{ 144 | //char *errorMsg; 145 | NSString *deleteString=[NSString stringWithFormat:@"%@ '%@';",kDeleteObjSql,aWord]; 146 | __strong const char *deleteSql=[deleteString UTF8String]; 147 | sqlite3_stmt *stmt; 148 | if (sqlite3_prepare(database, deleteSql, -1, &stmt, nil)==SQLITE_OK){ 149 | if (sqlite3_step(stmt)!=SQLITE_DONE){ 150 | //NSAssert(0,@"Error delete table:%s",errorMsg); 151 | sqlite3_finalize(stmt); 152 | return NO; 153 | } 154 | sqlite3_finalize(stmt); 155 | return YES; 156 | } 157 | sqlite3_finalize(stmt); 158 | return NO; 159 | } 160 | 161 | @end 162 | -------------------------------------------------------------------------------- /Classes/MKWebService_1.1.0/MKServiceManager.m: -------------------------------------------------------------------------------- 1 | // 2 | // MKServiceManager.m 3 | // MKNetSaveCard 4 | // 5 | // Created by tanhao on 11-8-15. 6 | // Copyright 2011年 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import "MKServiceManager.h" 10 | 11 | static MKServiceManager *instance=nil; 12 | 13 | @implementation MKServiceManager 14 | 15 | - (id)init 16 | { 17 | self = [super init]; 18 | if (self) { 19 | delegates = [[NSMutableArray alloc] init]; 20 | downloaders = [[NSMutableArray alloc] init]; 21 | contexts=[[NSMutableArray alloc] init]; 22 | } 23 | 24 | return self; 25 | } 26 | 27 | - (id)retain{ 28 | return self; 29 | } 30 | 31 | - (id)autorelease{ 32 | return self; 33 | } 34 | 35 | - (oneway void)release{ 36 | return ; 37 | } 38 | 39 | - (NSUInteger)retainCount{ 40 | return NSUIntegerMax; 41 | } 42 | 43 | - (void)dealloc 44 | { 45 | [delegates release], delegates = nil; 46 | [downloaders release], downloaders = nil; 47 | [contexts release], contexts = nil; 48 | [super dealloc]; 49 | } 50 | 51 | + (id)sharedManager 52 | { 53 | if (instance == nil) 54 | { 55 | instance = [[MKServiceManager alloc] init]; 56 | } 57 | return instance; 58 | } 59 | 60 | #pragma mark - 61 | #pragma mark CustomMethod 62 | 63 | - (void)cancelForDelegate:(id)delegate 64 | { 65 | NSUInteger idx = [delegates indexOfObjectIdenticalTo:delegate]; 66 | 67 | if (idx == NSNotFound) 68 | { 69 | return; 70 | } 71 | 72 | MKWebService *webService = [[downloaders objectAtIndex:idx] retain]; 73 | 74 | [delegates removeObjectAtIndex:idx]; 75 | [downloaders removeObjectAtIndex:idx]; 76 | [contexts removeObjectAtIndex:idx]; 77 | 78 | [webService release]; 79 | } 80 | 81 | - (void)uploadWithURL:(NSURL *)url delegate:(id)delegate postDic:(NSDictionary *)dic context:(id)context 82 | { 83 | if (!url || !delegate || !dic) { 84 | return; 85 | } 86 | if (!context) { 87 | context=[NSNull null]; 88 | } 89 | 90 | MKWebService *webService=[[[MKWebService alloc] init] autorelease]; 91 | webService.url=url; 92 | webService.delegate=self; 93 | [webService uploadDic:dic]; 94 | 95 | [delegates addObject:delegate]; 96 | [downloaders addObject:webService]; 97 | [contexts addObject:context]; 98 | } 99 | 100 | - (void)downloadWithURL:(NSURL *)url delegate:(id)delegate context:(id)context{ 101 | if (!url || !delegate) { 102 | return; 103 | } 104 | if (!context) { 105 | context=[NSNull null]; 106 | } 107 | 108 | MKWebService *webService=[[[MKWebService alloc] init] autorelease]; 109 | webService.url=url; 110 | webService.delegate=self; 111 | [webService downloadBlob]; 112 | 113 | [delegates addObject:delegate]; 114 | [downloaders addObject:webService]; 115 | [contexts addObject:context]; 116 | } 117 | 118 | #pragma mark - 119 | #pragma mark MKWebServiceDelegate 120 | 121 | - (void)webServiceBegin:(MKWebService *)webService{ 122 | 123 | } 124 | 125 | - (void)webServiceFinish:(MKWebService *)webService didReceiveData:(NSData *)data 126 | { 127 | [webService retain]; 128 | for (NSInteger idx = [downloaders count] - 1; idx >= 0; idx--) 129 | { 130 | MKWebService *aWebService = [downloaders objectAtIndex:idx]; 131 | if (aWebService == webService) 132 | { 133 | id delegate = [delegates objectAtIndex:idx]; 134 | id context=[contexts objectAtIndex:idx]; 135 | if ([context isKindOfClass:[NSNull class]]) { 136 | context=nil; 137 | } 138 | 139 | if (data) 140 | { 141 | if ([delegate respondsToSelector:@selector(serviceFinish:didReceiveData:context:)]) 142 | { 143 | [delegate serviceFinish:self didReceiveData:data context:context]; 144 | } 145 | } 146 | else 147 | { 148 | if ([delegate respondsToSelector:@selector(servicFail:didFailWithError:context:)]) 149 | { 150 | [delegate servicFail:self didFailWithError:nil context:context]; 151 | } 152 | } 153 | 154 | [downloaders removeObjectAtIndex:idx]; 155 | [delegates removeObjectAtIndex:idx]; 156 | [contexts removeObjectAtIndex:idx]; 157 | } 158 | } 159 | [webService release]; 160 | } 161 | 162 | - (void)webServiceFail:(MKWebService *)webService didFailWithError:(NSError *)error 163 | { 164 | [webService retain]; 165 | for (NSInteger idx = [downloaders count] - 1; idx >= 0; idx--) 166 | { 167 | MKWebService *aWebService = [downloaders objectAtIndex:idx]; 168 | if (aWebService == webService) 169 | { 170 | id delegate = [delegates objectAtIndex:idx]; 171 | id context=[contexts objectAtIndex:idx]; 172 | if ([context isKindOfClass:[NSNull class]]) { 173 | context=nil; 174 | } 175 | 176 | if ([delegate respondsToSelector:@selector(servicFail:didFailWithError:context:)]) 177 | { 178 | [delegate servicFail:self didFailWithError:error context:context]; 179 | } 180 | 181 | [downloaders removeObjectAtIndex:idx]; 182 | [delegates removeObjectAtIndex:idx]; 183 | [contexts removeObjectAtIndex:idx]; 184 | } 185 | } 186 | [webService release]; 187 | } 188 | 189 | @end 190 | -------------------------------------------------------------------------------- /Classes/SentenceViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // SentenceViewController.m 3 | // MKDic 4 | // 5 | // Created by stm on 11-6-16. 6 | // Copyright 2011 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import "SentenceViewController.h" 10 | #import "GeneralManager.h" 11 | #import "GDataXMLNode.h" 12 | 13 | 14 | @interface SentenceViewController() 15 | - (void)translateEnd; 16 | @end 17 | 18 | static NSString *allLanguage[]={ 19 | @"zh-CHS",@"en",@"ja" 20 | }; 21 | static NSString *bingKey = @"408DC1DA22200F983E20EAC99A1D283A5EC5AB79"; 22 | 23 | @implementation SentenceViewController 24 | 25 | - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil 26 | { 27 | self=[super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 28 | if (self) 29 | { 30 | translates=[[NSMutableArray alloc] init]; 31 | } 32 | return self; 33 | } 34 | 35 | - (void)loadView 36 | { 37 | [super loadView]; 38 | 39 | NSInteger fromIndex=1; 40 | NSInteger toIndex=0; 41 | fromLanguage=allLanguage[fromIndex]; 42 | toLanguage=allLanguage[toIndex]; 43 | 44 | [fromPopUpButton selectItemAtIndex:fromIndex]; 45 | [toPopUpButton selectItemAtIndex:toIndex]; 46 | 47 | fromTextView.delegate=self; 48 | } 49 | 50 | - (void)dealloc{ 51 | [translates release]; 52 | [super dealloc]; 53 | } 54 | 55 | #pragma mark - 56 | #pragma mark CustomFunc 57 | 58 | - (IBAction)buttonChange:(NSPopUpButton *)sender 59 | { 60 | NSInteger index=[sender indexOfSelectedItem]; 61 | if (sender==fromPopUpButton) { 62 | fromLanguage=allLanguage[index]; 63 | }else { 64 | toLanguage=allLanguage[index]; 65 | } 66 | 67 | } 68 | 69 | - (IBAction)translateBegin:(NSButton *)sender 70 | { 71 | [[GeneralManager shareManager] stopSpeak]; 72 | 73 | NSString *string=[fromTextView string]; 74 | if ([string length]==0) 75 | { 76 | return; 77 | } 78 | 79 | NSString *urlStr = [NSString stringWithFormat:@"http://api.microsofttranslator.com/V2/http.svc/translate?appId=%@&text=%@&from=%@&to=%@",bingKey,string,fromLanguage,toLanguage]; 80 | urlStr = [urlStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; 81 | [[MKServiceManager sharedManager] cancelForDelegate:self]; 82 | [[MKServiceManager sharedManager] downloadWithURL:[NSURL URLWithString:urlStr] delegate:self context:nil]; 83 | 84 | [toTextView setString:@"请等待⋯⋯"]; 85 | return; 86 | } 87 | 88 | - (IBAction)changeClick:(NSButton *)sender 89 | { 90 | NSInteger fromIndex=[fromPopUpButton indexOfSelectedItem]; 91 | NSInteger toIndex=[toPopUpButton indexOfSelectedItem]; 92 | 93 | fromLanguage=allLanguage[toIndex]; 94 | toLanguage=allLanguage[fromIndex]; 95 | 96 | [fromPopUpButton selectItemAtIndex:toIndex]; 97 | [toPopUpButton selectItemAtIndex:fromIndex]; 98 | } 99 | 100 | - (IBAction)talkClick:(NSButton *)sender 101 | { 102 | 103 | NSInteger fromIndex=[fromPopUpButton indexOfSelectedItem]; 104 | NSInteger toIndex=[toPopUpButton indexOfSelectedItem]; 105 | if (fromIndex==1) { 106 | [[GeneralManager shareManager] speakWithText:[fromTextView string]]; 107 | } 108 | else if(toIndex==1){ 109 | [[GeneralManager shareManager] speakWithText:[toTextView string]]; 110 | } 111 | } 112 | 113 | #pragma mark - 114 | #pragma mark MKServiceManagerDelegate 115 | 116 | - (void)serviceFinish:(MKServiceManager *)webService didReceiveData:(NSData *)data context:(id)context 117 | { 118 | NSError *error; 119 | GDataXMLDocument* document = [[GDataXMLDocument alloc] initWithData:data options:0 error:&error]; 120 | GDataXMLElement *rootNode = [document rootElement]; 121 | NSString *stingline = [rootNode stringValue]; 122 | if (stingline.length == 0) 123 | { 124 | stingline = @"没有找到结果!"; 125 | } 126 | 127 | [toTextView setString:stingline]; 128 | [document release]; 129 | [self translateEnd]; 130 | } 131 | 132 | - (void)servicFail:(MKServiceManager *)webService didFailWithError:(NSError *)error context:(id)context 133 | { 134 | [toTextView setString:@"加载超时,请检查是否连接网络⋯⋯"]; 135 | } 136 | 137 | #pragma mark - 138 | #pragma mark CustomTextViewDelegate 139 | 140 | - (void)enterClick:(id)sender 141 | { 142 | [self translateBegin:nil]; 143 | } 144 | 145 | - (void)rightMenuItemClick:(NSString *)aText 146 | { 147 | [[NSNotificationCenter defaultCenter] postNotificationName:kNotificationSearchWorld object:aText userInfo:nil]; 148 | } 149 | 150 | #pragma mark - 151 | #pragma mark CustomViewControllerProtocol 152 | 153 | - (void)quickTranslateWithString:(NSString *)str 154 | { 155 | [fromTextView setString:str]; 156 | [self translateBegin:nil]; 157 | } 158 | 159 | - (void)setFirstResponder 160 | { 161 | [[fromTextView superview] becomeFirstResponder]; 162 | } 163 | 164 | - (void)changeFont:(NSFont *)aFont 165 | { 166 | [fromTextView setFont:aFont]; 167 | [toTextView setFont:aFont]; 168 | } 169 | 170 | - (void)translateEnd 171 | { 172 | while ([translates count]>displayIndex+1) 173 | { 174 | [translates removeLastObject]; 175 | } 176 | 177 | NSString *searchVal=[NSString stringWithString:[fromTextView string]]; 178 | NSString *translVal=[NSString stringWithString:[toTextView string]]; 179 | NSArray *currentTrans=[[NSArray alloc] initWithObjects:searchVal,translVal,nil]; 180 | [translates addObject:currentTrans]; 181 | [currentTrans release]; 182 | 183 | displayIndex=[translates count]-1; 184 | } 185 | 186 | - (void)undoAction 187 | { 188 | if (displayIndex>0) 189 | { 190 | --displayIndex; 191 | NSArray *currentTrans=[translates objectAtIndex:displayIndex]; 192 | [fromTextView setString:(NSString *)[currentTrans objectAtIndex:0]]; 193 | [toTextView setString:(NSString *)[currentTrans objectAtIndex:1]]; 194 | } 195 | } 196 | 197 | - (void)redoAction 198 | { 199 | if ([translates count]>displayIndex+1) 200 | { 201 | ++displayIndex; 202 | NSArray *currentTrans=[translates objectAtIndex:displayIndex]; 203 | [fromTextView setString:(NSString *)[currentTrans objectAtIndex:0]]; 204 | [toTextView setString:(NSString *)[currentTrans objectAtIndex:1]]; 205 | } 206 | } 207 | 208 | @end 209 | -------------------------------------------------------------------------------- /Classes/StudyViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // StudyViewController.m 3 | // MKDic 4 | // 5 | // Created by stm on 11-6-17. 6 | // Copyright 2011 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import "StudyViewController.h" 10 | #import "GeneralManager.h" 11 | #import "GDataXMLNode.h" 12 | #import "WordNoteDao.h" 13 | 14 | @implementation StudyViewController 15 | @synthesize objArray; 16 | 17 | - (IBAction)addLevel:(NSButton *)sender{ 18 | NSInteger selectedRow=[currentTableView selectedRow]; 19 | if (selectedRow<0) { 20 | return; 21 | } 22 | WordNote *wordNode=[objArray objectAtIndex:selectedRow]; 23 | if (wordNode.level<3) { 24 | wordNode.level++; 25 | 26 | [[WordNoteDao shareDao] insertWordNote:wordNode]; 27 | NSIndexSet *rowIndexes=[NSIndexSet indexSetWithIndex:selectedRow]; 28 | NSIndexSet *columnIndexes=[NSIndexSet indexSetWithIndex:1]; 29 | [currentTableView reloadDataForRowIndexes:rowIndexes columnIndexes:columnIndexes]; 30 | } 31 | } 32 | 33 | - (IBAction)minusLevel:(NSButton *)sender{ 34 | NSInteger selectedRow=[currentTableView selectedRow]; 35 | if (selectedRow<0) { 36 | return; 37 | } 38 | WordNote *wordNode=[objArray objectAtIndex:selectedRow]; 39 | if (wordNode.level>0) { 40 | wordNode.level--; 41 | 42 | [[WordNoteDao shareDao] insertWordNote:wordNode]; 43 | NSIndexSet *rowIndexes=[NSIndexSet indexSetWithIndex:selectedRow]; 44 | NSIndexSet *columnIndexes=[NSIndexSet indexSetWithIndex:1]; 45 | [currentTableView reloadDataForRowIndexes:rowIndexes columnIndexes:columnIndexes]; 46 | } 47 | } 48 | 49 | - (IBAction)deleteWord:(NSButton *)sender{ 50 | NSInteger selectedRow=[currentTableView selectedRow]; 51 | if (selectedRow<0) { 52 | return; 53 | } 54 | WordNote *wordNode=[objArray objectAtIndex:selectedRow]; 55 | [[WordNoteDao shareDao] deleteWordNote:wordNode.word]; 56 | [self.objArray removeObjectAtIndex:selectedRow]; 57 | [currentTableView reloadData]; 58 | 59 | //刷新表格之后取得新的选中项 60 | selectedRow=[currentTableView selectedRow]; 61 | if (selectedRow<0) { 62 | return; 63 | } 64 | wordNode=[objArray objectAtIndex:selectedRow]; 65 | [studyTextView setString:wordNode.translate]; 66 | } 67 | 68 | - (IBAction)talkClick:(NSButton *)sender{ 69 | NSInteger selectedRow=[currentTableView selectedRow]; 70 | if (selectedRow<0) { 71 | return; 72 | } 73 | WordNote *wordNode=[objArray objectAtIndex:selectedRow]; 74 | [[GeneralManager shareManager] speakWithText:wordNode.word]; 75 | } 76 | 77 | #pragma mark - 78 | #pragma mark NSTableViewDataSource 79 | 80 | - (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView{ 81 | return [objArray count]; 82 | } 83 | 84 | - (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row{ 85 | 86 | //NSDictionary *attr = [NSDictionary dictionaryWithObjectsAndKeys:[NSFont systemFontOfSize:12.0], NSFontAttributeName, nil]; 87 | //return [[[NSAttributedString alloc] initWithString:@"Test" attributes:attr] autorelease]; 88 | 89 | WordNote *wordNode=[objArray objectAtIndex:row]; 90 | if ([[tableView tableColumns] indexOfObject:tableColumn]==0) { 91 | return wordNode.word; 92 | }else { 93 | return [NSNumber numberWithInt:wordNode.level]; 94 | } 95 | } 96 | 97 | - (void)tableView:(NSTableView *)tableView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row{ 98 | WordNote *wordNode=[objArray objectAtIndex:row]; 99 | wordNode.level=[object intValue]; 100 | [[WordNoteDao shareDao] insertWordNote:wordNode]; 101 | 102 | NSIndexSet *rowIndexes=[NSIndexSet indexSetWithIndex:row]; 103 | NSIndexSet *columnIndexes=[NSIndexSet indexSetWithIndex:1]; 104 | [tableView reloadDataForRowIndexes:rowIndexes columnIndexes:columnIndexes]; 105 | } 106 | 107 | #pragma mark - 108 | #pragma mark NSTableViewDelegate 109 | 110 | - (BOOL)tableView:(NSTableView *)tableView shouldSelectRow:(NSInteger)row{ 111 | WordNote *wordNode=[objArray objectAtIndex:row]; 112 | [studyTextView setString:wordNode.translate]; 113 | return YES; 114 | } 115 | 116 | - (BOOL)selectionShouldChangeInTableView:(NSTableView *)tableView{ 117 | return YES; 118 | } 119 | 120 | - (void)tableView:(NSTableView *)tableView mouseDownInHeaderOfTableColumn:(NSTableColumn *)tableColumn{ 121 | 122 | NSString *sortKey=nil; //按哪个键排序 123 | BOOL ascending; 124 | static BOOL wordAscending=YES; //单词升序 125 | static BOOL levelAscending=YES; //熟练升序 126 | 127 | 128 | if ([[tableView tableColumns] indexOfObject:tableColumn]==0) { 129 | wordAscending=!wordAscending; 130 | ascending=wordAscending; 131 | sortKey=@"word"; 132 | }else { 133 | levelAscending=!levelAscending; 134 | ascending=levelAscending; 135 | sortKey=@"level"; 136 | } 137 | 138 | NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:sortKey ascending:ascending]; 139 | NSArray *sortDescriptors = [NSArray arrayWithObject:sortDescriptor]; 140 | [objArray sortUsingDescriptors:sortDescriptors]; 141 | [sortDescriptor release]; 142 | 143 | [tableView reloadData]; 144 | 145 | NSInteger selectedRow=[currentTableView selectedRow]; 146 | if (selectedRow>=0) { 147 | WordNote *wordNode=[objArray objectAtIndex:selectedRow]; 148 | [studyTextView setString:wordNode.translate]; 149 | } 150 | } 151 | 152 | #pragma mark - 153 | #pragma mark CustomViewControllerProtocol 154 | 155 | - (void)setFirstResponder{ 156 | self.objArray=[NSMutableArray arrayWithArray:[[WordNoteDao shareDao] selectAll]]; 157 | [currentTableView reloadData]; 158 | return; 159 | } 160 | 161 | - (void)changeFont:(NSFont *)aFont{ 162 | [studyTextView setFont:aFont]; 163 | } 164 | 165 | - (void)undoAction{ 166 | return; 167 | } 168 | 169 | - (void)redoAction{ 170 | return; 171 | } 172 | 173 | - (void)quickTranslateWithString:(NSString *)str 174 | { 175 | return; 176 | } 177 | 178 | #pragma mark - 179 | #pragma mark CustomTextViewDelegate 180 | 181 | - (void)rightMenuItemClick:(NSString *)aText{ 182 | [[NSNotificationCenter defaultCenter] postNotificationName:kNotificationSearchWorld object:aText userInfo:nil]; 183 | } 184 | 185 | @end 186 | -------------------------------------------------------------------------------- /Classes/MKWebService_1.1.0/MKWebService.m: -------------------------------------------------------------------------------- 1 | // 2 | // MKWebService.m 3 | // MKNetSaveCard 4 | // 5 | // Created by tanhao on 11-8-3. 6 | // Copyright 2011 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import "MKWebService.h" 10 | 11 | static NSString *kBoundaryStr=@"_insert_some_boundary_here_"; 12 | 13 | @interface MKWebService() 14 | 15 | //将字典按照HTTP的协议进行编码 16 | - (NSData*)generateFormData:(NSDictionary*)dict; 17 | 18 | @property (nonatomic, retain) NSURLConnection *con; 19 | @property (nonatomic, retain) NSMutableData *data; 20 | @end 21 | 22 | @implementation MKWebService 23 | @synthesize delegate=_delegate; 24 | @synthesize url=_url; 25 | @synthesize con=_con; 26 | @synthesize data=_data; 27 | 28 | - (id)init{ 29 | self=[super init]; 30 | if (self) { 31 | ; 32 | } 33 | return self; 34 | } 35 | 36 | - (void)dealloc{ 37 | [_url release]; 38 | [_con cancel]; 39 | [_con release]; 40 | [_data release]; 41 | [super dealloc]; 42 | } 43 | 44 | - (NSData*)generateFormData:(NSDictionary*)dict 45 | { 46 | NSString* boundary = [NSString stringWithString:kBoundaryStr]; 47 | NSArray* keys = [dict allKeys]; 48 | NSMutableData* result = [[NSMutableData alloc] init]; 49 | 50 | NSStringEncoding encoding = NSASCIIStringEncoding;//NSUTF8StringEncoding; //NSASCIIStringEncoding; 51 | for (int i = 0; i < [keys count]; i++) 52 | { 53 | id value = [dict valueForKey: [keys objectAtIndex: i]]; 54 | [result appendData:[[NSString stringWithFormat:@"--%@\r\n", boundary] dataUsingEncoding:encoding]]; 55 | if ([value isKindOfClass:[NSString class]]) 56 | { 57 | [result appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"%@\"\r\n\r\n", [keys objectAtIndex:i]] dataUsingEncoding:encoding]]; 58 | [result appendData:[[NSString stringWithFormat:@"%@",value] dataUsingEncoding:encoding]]; 59 | } 60 | if ([value isKindOfClass:[NSNumber class]]) 61 | { 62 | [result appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"%@\"\r\n\r\n", [keys objectAtIndex:i]] dataUsingEncoding:encoding]]; 63 | [result appendData:[[value stringValue] dataUsingEncoding:encoding]]; 64 | } 65 | else if ([value isKindOfClass:[NSURL class]] && [value isFileURL]) 66 | { 67 | [result appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"%@\"; filename=\"%@\"\r\n", [keys objectAtIndex:i], [[value path] lastPathComponent]] dataUsingEncoding:encoding]]; 68 | [result appendData:[[NSString stringWithString:@"Content-Type: application/octet-stream\r\n\r\n"] dataUsingEncoding:encoding]]; 69 | [result appendData:[NSData dataWithContentsOfFile:[value path]]]; 70 | } 71 | else if ([value isKindOfClass:[NSData class]]) 72 | { 73 | [result appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"%@\"\r\n\r\n", [keys objectAtIndex:i]] dataUsingEncoding:encoding]]; 74 | [result appendData:value]; 75 | } 76 | [result appendData:[[NSString stringWithString:@"\r\n"] dataUsingEncoding:encoding]]; 77 | } 78 | [result appendData:[[NSString stringWithFormat:@"--%@--\r\n", boundary] dataUsingEncoding:encoding]]; 79 | 80 | return [result autorelease]; 81 | } 82 | 83 | #pragma mark - 84 | #pragma mark CustomMethod 85 | 86 | - (void)uploadDic:(NSDictionary *)dic{ 87 | [_con cancel]; 88 | NSMutableData *aData=[[NSMutableData alloc] init]; 89 | self.data=aData; 90 | [aData release]; 91 | 92 | NSMutableURLRequest *request=[[NSMutableURLRequest alloc] initWithURL:_url 93 | cachePolicy:NSURLRequestUseProtocolCachePolicy 94 | timeoutInterval:15.0]; 95 | //设置request的属性和Header 96 | [request setHTTPMethod:@"POST"]; 97 | NSString *header_type = [NSString stringWithFormat:@"multipart/form-data; boundary=%@",kBoundaryStr]; 98 | [request addValue: header_type forHTTPHeaderField: @"Content-Type"]; 99 | //设置一些特殊的Header(伪装) 100 | //[request setValue:@"http://website.com" forHTTPHeaderField:@"Referer"]; 101 | //[request setValue:@"http://website.com" forHTTPHeaderField:@"User-Agent"]; 102 | 103 | //按照HTTP的相关协议格式化数据 104 | NSData *postData=[self generateFormData:dic]; 105 | [request addValue:[NSString stringWithFormat:@"%d",[postData length]] forHTTPHeaderField:@"Content-Length"]; 106 | [request setHTTPBody:postData]; 107 | 108 | //发起网络链接 109 | NSURLConnection *connection=[[NSURLConnection alloc] initWithRequest:request delegate:self startImmediately:YES]; 110 | self.con=connection; 111 | [request release]; 112 | [connection release]; 113 | } 114 | 115 | - (void)downloadBlob{ 116 | [_con cancel]; 117 | NSMutableData *aData=[[NSMutableData alloc] init]; 118 | self.data=aData; 119 | [aData release]; 120 | 121 | NSMutableURLRequest *request=[[NSMutableURLRequest alloc] initWithURL:_url 122 | cachePolicy:NSURLRequestUseProtocolCachePolicy 123 | timeoutInterval:15.0]; 124 | NSString* date = [request valueForHTTPHeaderField:@"Date"]; 125 | if (!date) 126 | { 127 | NSString* dateFormat = @"EEE, dd MMM yyyy HH:mm:ss ZZZ"; 128 | NSDateFormatter *format = [[NSDateFormatter alloc] init]; 129 | [format setDateFormat:dateFormat]; 130 | [format setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"GMT"]]; 131 | date = [format stringFromDate:[NSDate date]]; 132 | [request setValue:date forHTTPHeaderField:@"Date"]; 133 | } 134 | [request setHTTPMethod:@"GET"]; 135 | NSURLConnection *connection=[[NSURLConnection alloc] initWithRequest:request delegate:self startImmediately:YES]; 136 | self.con=connection; 137 | [request release]; 138 | [connection release]; 139 | } 140 | 141 | #pragma mark - 142 | #pragma mark NSURLConnectionDelegate 143 | 144 | - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response{ 145 | if ([_delegate respondsToSelector:@selector(webServiceBegin:)]) { 146 | [_delegate webServiceBegin:self]; 147 | } 148 | } 149 | 150 | -(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)aData{ 151 | if(_con!=nil){ 152 | [_data appendData:aData]; 153 | } 154 | } 155 | 156 | -(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error{ 157 | if ([_delegate respondsToSelector:@selector(webServiceFail:didFailWithError:)]) { 158 | [_delegate webServiceFail:self didFailWithError:error]; 159 | } 160 | } 161 | 162 | -(void)connectionDidFinishLoading:(NSURLConnection *)connection{ 163 | if ([_delegate respondsToSelector:@selector(webServiceFinish:didReceiveData:)]) { 164 | [_delegate webServiceFinish:self didReceiveData:_data]; 165 | } 166 | } 167 | 168 | @end 169 | -------------------------------------------------------------------------------- /Classes/MainViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // MainViewController.m 3 | // MKDic 4 | // 5 | // Created by stm on 11-6-16. 6 | // Copyright 2011 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import "MainViewController.h" 10 | #import "WordsViewController.h" 11 | #import "SentenceViewController.h" 12 | #import "StudyViewController.h" 13 | 14 | @interface MainViewController() 15 | - (void)changeViewWithIndex:(NSInteger)index; 16 | @end 17 | 18 | @implementation MainViewController 19 | 20 | - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil{ 21 | self=[super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 22 | if (self) { 23 | WordsViewController *wordsViewController=[[WordsViewController alloc] initWithNibName:@"WordsViewController" bundle:nil]; 24 | SentenceViewController *sentenceViewController=[[SentenceViewController alloc] initWithNibName:@"SentenceViewController" bundle:nil]; 25 | StudyViewController *studyViewController=[[StudyViewController alloc] initWithNibName:@"StudyViewController" bundle:nil]; 26 | 27 | viewControllerArray=[[NSArray alloc] initWithObjects:wordsViewController,sentenceViewController,studyViewController,nil]; 28 | [wordsViewController release]; 29 | [sentenceViewController release]; 30 | [studyViewController release]; 31 | 32 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveNotification:) name:kNotificationSearchWorld object:nil]; 33 | } 34 | return self; 35 | } 36 | 37 | - (void)receiveNotification:(NSNotification *)aNotification{ 38 | [self changeViewWithIndex:0]; 39 | } 40 | 41 | - (void)loadView{ 42 | [super loadView]; 43 | 44 | for(NSViewController *viewController in viewControllerArray){ 45 | [self.view addSubview:viewController.view positioned:NSWindowBelow relativeTo:nil]; 46 | } 47 | [self changeViewWithIndex:0]; 48 | [segmentedControl setSelectedSegment:0]; 49 | } 50 | 51 | - (void)dealloc{ 52 | [[NSNotificationCenter defaultCenter] removeObserver:self]; 53 | [viewControllerArray release]; 54 | [super dealloc]; 55 | } 56 | 57 | #pragma mark - 58 | #pragma mark CustomFunc 59 | 60 | - (void)changeViewWithIndex:(NSInteger)index{ 61 | for (NSViewController *viewController in viewControllerArray) { 62 | [viewController.view setHidden:YES]; 63 | } 64 | currentViewController=[viewControllerArray objectAtIndex:index]; 65 | [currentViewController.view setHidden:NO]; 66 | [currentViewController setFirstResponder]; 67 | 68 | if (index==2) { 69 | [undoSegmentControl setHidden:YES]; 70 | }else { 71 | [undoSegmentControl setHidden:NO]; 72 | } 73 | 74 | } 75 | 76 | - (IBAction)segmentClick:(NSSegmentedControl *)sender{ 77 | [self changeViewWithIndex:[sender selectedSegment]]; 78 | } 79 | 80 | - (IBAction)fontChangeClick:(NSSegmentedControl *)sender{ 81 | CGFloat size=12.0; 82 | NSString *name=@"STHeitiSC-Light"; 83 | NSFont *selectFont = [[NSFontManager sharedFontManager] selectedFont]; 84 | if (selectFont!=nil) { 85 | size=[selectFont pointSize]; 86 | name=[selectFont fontName]; 87 | } 88 | 89 | if ([sender selectedSegment]==0) { 90 | size-=2; 91 | }else { 92 | size+=2; 93 | } 94 | 95 | selectFont=[NSFont fontWithName:name size:size]; 96 | [[NSFontManager sharedFontManager] setSelectedFont:selectFont isMultiple:NO]; 97 | 98 | [currentViewController changeFont:selectFont]; 99 | } 100 | 101 | - (IBAction)undoClick:(NSSegmentedControl *)sender{ 102 | if ([sender selectedSegment]==0) { 103 | [currentViewController undoAction]; 104 | }else { 105 | [currentViewController redoAction]; 106 | } 107 | } 108 | 109 | - (IBAction)supportClick:(id)sender 110 | { 111 | [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://www.tanhao.me"]]; 112 | } 113 | 114 | #pragma mark - 115 | #pragma mark Service 116 | 117 | - (NSString *)getStringWith:(NSPasteboard *)pboard 118 | userData:(NSString *)data // typed as what we handle 119 | error:(NSString **)error 120 | { 121 | NSString *pboardString; 122 | NSString *newString; 123 | NSArray *types; 124 | 125 | types = [pboard types]; 126 | 127 | // if there's a problem with the data passed to this method 128 | if(![types containsObject:NSStringPboardType] || 129 | !(pboardString = [pboard stringForType:NSStringPboardType])) 130 | { 131 | *error = NSLocalizedString(@"Error: Pasteboard doesn't contain a string.", 132 | @"Pasteboard couldn't give a string."); 133 | // if there's a problem then it'll be sure to tell us! 134 | return NSLocalizedString(@"Error: Pasteboard doesn't contain a string.", 135 | @"Pasteboard couldn't give a string."); 136 | } 137 | 138 | // here is where our capitalizing code goes 139 | newString = [pboardString capitalizedString]; // it's that easy! 140 | 141 | // the next block checks to see if there was an error while capitalizing 142 | if(!newString) 143 | { 144 | *error = NSLocalizedString(@"Error: Couldn't capitalize string $@.", 145 | @"Couldn't perform service operation."); 146 | // again, it lets us know of any trouble 147 | return NSLocalizedString(@"Error: Couldn't capitalize string $@.", 148 | @"Couldn't perform service operation."); 149 | } 150 | 151 | // the next bit tells the system what it's returning 152 | types = [NSArray arrayWithObject:NSStringPboardType]; 153 | 154 | [pboard declareTypes:types 155 | owner:nil]; 156 | 157 | // and then this sets the string to our capitalized version 158 | [pboard setString:newString 159 | forType:NSStringPboardType]; 160 | 161 | return newString; 162 | } 163 | 164 | - (void)srvSearch:(NSPasteboard *)pboard 165 | userData:(NSString *)data // typed as what we handle 166 | error:(NSString **)error 167 | { 168 | NSString *string = [self getStringWith:pboard userData:data error:error]; 169 | [self changeViewWithIndex:0]; 170 | [currentViewController quickTranslateWithString:string]; 171 | [segmentedControl setSelectedSegment:0]; 172 | [self.view.window makeKeyAndOrderFront:self]; 173 | } 174 | 175 | - (void)srvTranslate:(NSPasteboard *)pboard 176 | userData:(NSString *)data // typed as what we handle 177 | error:(NSString **)error 178 | { 179 | NSString *string = [self getStringWith:pboard userData:data error:error]; 180 | [self changeViewWithIndex:1]; 181 | [currentViewController quickTranslateWithString:string]; 182 | [segmentedControl setSelectedSegment:1]; 183 | [self.view.window makeKeyAndOrderFront:self]; 184 | } 185 | 186 | 187 | 188 | @end 189 | -------------------------------------------------------------------------------- /Classes/TouchJSON/JSON/CJSONSerializer.m: -------------------------------------------------------------------------------- 1 | // 2 | // CJSONSerializer.m 3 | // TouchJSON 4 | // 5 | // Created by Jonathan Wight on 12/07/2005. 6 | // Copyright (c) 2005 Jonathan Wight 7 | // 8 | // Permission is hereby granted, free of charge, to any person 9 | // obtaining a copy of this software and associated documentation 10 | // files (the "Software"), to deal in the Software without 11 | // restriction, including without limitation the rights to use, 12 | // copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the 14 | // Software is furnished to do so, subject to the following 15 | // conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 22 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 24 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 25 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 26 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 27 | // OTHER DEALINGS IN THE SOFTWARE. 28 | // 29 | 30 | #import "CJSONSerializer.h" 31 | 32 | @implementation CJSONSerializer 33 | 34 | + (id)serializer 35 | { 36 | return([[[self alloc] init] autorelease]); 37 | } 38 | 39 | - (NSString *)serializeObject:(id)inObject; 40 | { 41 | NSString *theResult = @""; 42 | 43 | if ([inObject isKindOfClass:[NSNull class]]) 44 | { 45 | theResult = [self serializeNull:inObject]; 46 | } 47 | else if ([inObject isKindOfClass:[NSNumber class]]) 48 | { 49 | theResult = [self serializeNumber:inObject]; 50 | } 51 | else if ([inObject isKindOfClass:[NSString class]]) 52 | { 53 | theResult = [self serializeString:inObject]; 54 | } 55 | else if ([inObject isKindOfClass:[NSArray class]]) 56 | { 57 | theResult = [self serializeArray:inObject]; 58 | } 59 | else if ([inObject isKindOfClass:[NSDictionary class]]) 60 | { 61 | theResult = [self serializeDictionary:inObject]; 62 | } 63 | else if ([inObject isKindOfClass:[NSData class]]) 64 | { 65 | NSString *theString = [[[NSString alloc] initWithData:inObject encoding:NSUTF8StringEncoding] autorelease]; 66 | theResult = [self serializeString:theString]; 67 | } 68 | else 69 | { 70 | [NSException raise:NSGenericException format:@"Cannot serialize data of type '%@'", NSStringFromClass([inObject class])]; 71 | } 72 | if (theResult == NULL) 73 | [NSException raise:NSGenericException format:@"Could not serialize object '%@'", inObject]; 74 | return(theResult); 75 | } 76 | 77 | - (NSString *)serializeNull:(NSNull *)inNull 78 | { 79 | #pragma unused (inNull) 80 | return(@"null"); 81 | } 82 | 83 | - (NSString *)serializeNumber:(NSNumber *)inNumber 84 | { 85 | NSString *theResult = NULL; 86 | switch (CFNumberGetType((CFNumberRef)inNumber)) 87 | { 88 | case kCFNumberCharType: 89 | { 90 | int theValue = [inNumber intValue]; 91 | if (theValue == 0) 92 | theResult = @"false"; 93 | else if (theValue == 1) 94 | theResult = @"true"; 95 | else 96 | theResult = [inNumber stringValue]; 97 | } 98 | break; 99 | case kCFNumberSInt8Type: 100 | case kCFNumberSInt16Type: 101 | case kCFNumberSInt32Type: 102 | case kCFNumberSInt64Type: 103 | case kCFNumberFloat32Type: 104 | case kCFNumberFloat64Type: 105 | case kCFNumberShortType: 106 | case kCFNumberIntType: 107 | case kCFNumberLongType: 108 | case kCFNumberLongLongType: 109 | case kCFNumberFloatType: 110 | case kCFNumberDoubleType: 111 | case kCFNumberCFIndexType: 112 | default: 113 | theResult = [inNumber stringValue]; 114 | break; 115 | } 116 | return(theResult); 117 | } 118 | 119 | - (NSString *)serializeString:(NSString *)inString 120 | { 121 | NSMutableString *theMutableCopy = [[inString mutableCopy] autorelease]; 122 | [theMutableCopy replaceOccurrencesOfString:@"\\" withString:@"\\\\" options:0 range:NSMakeRange(0, [theMutableCopy length])]; 123 | [theMutableCopy replaceOccurrencesOfString:@"\"" withString:@"\\\"" options:0 range:NSMakeRange(0, [theMutableCopy length])]; 124 | [theMutableCopy replaceOccurrencesOfString:@"/" withString:@"\\/" options:0 range:NSMakeRange(0, [theMutableCopy length])]; 125 | [theMutableCopy replaceOccurrencesOfString:@"\b" withString:@"\\b" options:0 range:NSMakeRange(0, [theMutableCopy length])]; 126 | [theMutableCopy replaceOccurrencesOfString:@"\f" withString:@"\\f" options:0 range:NSMakeRange(0, [theMutableCopy length])]; 127 | [theMutableCopy replaceOccurrencesOfString:@"\n" withString:@"\\n" options:0 range:NSMakeRange(0, [theMutableCopy length])]; 128 | [theMutableCopy replaceOccurrencesOfString:@"\n" withString:@"\\n" options:0 range:NSMakeRange(0, [theMutableCopy length])]; 129 | [theMutableCopy replaceOccurrencesOfString:@"\t" withString:@"\\t" options:0 range:NSMakeRange(0, [theMutableCopy length])]; 130 | /* 131 | case 'u': 132 | { 133 | theCharacter = 0; 134 | 135 | int theShift; 136 | for (theShift = 12; theShift >= 0; theShift -= 4) 137 | { 138 | int theDigit = HexToInt([self scanCharacter]); 139 | if (theDigit == -1) 140 | { 141 | [self setScanLocation:theScanLocation]; 142 | return(NO); 143 | } 144 | theCharacter |= (theDigit << theShift); 145 | } 146 | } 147 | */ 148 | return([NSString stringWithFormat:@"\"%@\"", theMutableCopy]); 149 | } 150 | 151 | - (NSString *)serializeArray:(NSArray *)inArray 152 | { 153 | NSMutableString *theString = [NSMutableString string]; 154 | 155 | NSEnumerator *theEnumerator = [inArray objectEnumerator]; 156 | id theValue = NULL; 157 | while ((theValue = [theEnumerator nextObject]) != NULL) 158 | { 159 | [theString appendString:[self serializeObject:theValue]]; 160 | if (theValue != [inArray lastObject]) 161 | [theString appendString:@","]; 162 | } 163 | return([NSString stringWithFormat:@"[%@]", theString]); 164 | } 165 | 166 | - (NSString *)serializeDictionary:(NSDictionary *)inDictionary 167 | { 168 | NSMutableString *theString = [NSMutableString string]; 169 | 170 | NSArray *theKeys = [inDictionary allKeys]; 171 | NSEnumerator *theEnumerator = [theKeys objectEnumerator]; 172 | NSString *theKey = NULL; 173 | while ((theKey = [theEnumerator nextObject]) != NULL) 174 | { 175 | id theValue = [inDictionary objectForKey:theKey]; 176 | 177 | [theString appendFormat:@"%@:%@", [self serializeString:theKey], [self serializeObject:theValue]]; 178 | if (theKey != [theKeys lastObject]) 179 | [theString appendString:@","]; 180 | } 181 | return([NSString stringWithFormat:@"{%@}", theString]); 182 | } 183 | 184 | @end 185 | -------------------------------------------------------------------------------- /Classes/TouchJSON/CDataScanner.m: -------------------------------------------------------------------------------- 1 | // 2 | // CDataScanner.m 3 | // TouchJSON 4 | // 5 | // Created by Jonathan Wight on 04/16/08. 6 | // Copyright (c) 2008 Jonathan Wight 7 | // 8 | // Permission is hereby granted, free of charge, to any person 9 | // obtaining a copy of this software and associated documentation 10 | // files (the "Software"), to deal in the Software without 11 | // restriction, including without limitation the rights to use, 12 | // copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the 14 | // Software is furnished to do so, subject to the following 15 | // conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 22 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 24 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 25 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 26 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 27 | // OTHER DEALINGS IN THE SOFTWARE. 28 | // 29 | 30 | #import "CDataScanner.h" 31 | 32 | #import "CDataScanner_Extensions.h" 33 | 34 | @interface CDataScanner () 35 | @property (readwrite, nonatomic, retain) NSCharacterSet *doubleCharacters; 36 | @end 37 | 38 | #pragma mark - 39 | 40 | inline static unichar CharacterAtPointer(void *start, void *end) 41 | { 42 | #pragma unused(end) 43 | 44 | const u_int8_t theByte = *(u_int8_t *)start; 45 | if (theByte & 0x80) 46 | { 47 | // TODO -- UNICODE!!!! (well in theory nothing todo here) 48 | } 49 | const unichar theCharacter = theByte; 50 | return(theCharacter); 51 | } 52 | 53 | @implementation CDataScanner 54 | 55 | @dynamic data; 56 | @dynamic scanLocation; 57 | @dynamic isAtEnd; 58 | @synthesize doubleCharacters; 59 | 60 | + (id)scannerWithData:(NSData *)inData 61 | { 62 | CDataScanner *theScanner = [[[self alloc] init] autorelease]; 63 | theScanner.data = inData; 64 | return(theScanner); 65 | } 66 | 67 | - (id)init 68 | { 69 | if ((self = [super init]) != nil) 70 | { 71 | self.doubleCharacters = [NSCharacterSet characterSetWithCharactersInString:@"0123456789eE-."]; 72 | } 73 | return(self); 74 | } 75 | 76 | - (void)dealloc 77 | { 78 | self.data = NULL; 79 | self.doubleCharacters = NULL; 80 | // 81 | [super dealloc]; 82 | } 83 | 84 | - (NSUInteger)scanLocation 85 | { 86 | return(current - start); 87 | } 88 | 89 | - (NSData *)data 90 | { 91 | return(data); 92 | } 93 | 94 | - (void)setData:(NSData *)inData 95 | { 96 | if (data != inData) 97 | { 98 | if (data) 99 | { 100 | [data release]; 101 | data = NULL; 102 | } 103 | 104 | if (inData) 105 | { 106 | data = [inData retain]; 107 | // 108 | start = (u_int8_t *)data.bytes; 109 | end = start + data.length; 110 | current = start; 111 | length = data.length; 112 | } 113 | } 114 | } 115 | 116 | - (void)setScanLocation:(NSUInteger)inScanLocation 117 | { 118 | current = start + inScanLocation; 119 | } 120 | 121 | - (BOOL)isAtEnd 122 | { 123 | return(self.scanLocation >= length); 124 | } 125 | 126 | - (unichar)currentCharacter 127 | { 128 | return(CharacterAtPointer(current, end)); 129 | } 130 | 131 | #pragma mark - 132 | 133 | - (unichar)scanCharacter 134 | { 135 | const unichar theCharacter = CharacterAtPointer(current++, end); 136 | return(theCharacter); 137 | } 138 | 139 | - (BOOL)scanCharacter:(unichar)inCharacter 140 | { 141 | unichar theCharacter = CharacterAtPointer(current, end); 142 | if (theCharacter == inCharacter) 143 | { 144 | ++current; 145 | return(YES); 146 | } 147 | else 148 | return(NO); 149 | } 150 | 151 | - (BOOL)scanUTF8String:(const char *)inString intoString:(NSString **)outValue; 152 | { 153 | const size_t theLength = strlen(inString); 154 | if ((size_t)(end - current) < theLength) 155 | return(NO); 156 | if (strncmp((char *)current, inString, theLength) == 0) 157 | { 158 | current += theLength; 159 | if (outValue) 160 | *outValue = [NSString stringWithUTF8String:inString]; 161 | return(YES); 162 | } 163 | return(NO); 164 | } 165 | 166 | - (BOOL)scanString:(NSString *)inString intoString:(NSString **)outValue 167 | { 168 | if ((size_t)(end - current) < inString.length) 169 | return(NO); 170 | if (strncmp((char *)current, [inString UTF8String], inString.length) == 0) 171 | { 172 | current += inString.length; 173 | if (outValue) 174 | *outValue = inString; 175 | return(YES); 176 | } 177 | return(NO); 178 | } 179 | 180 | - (BOOL)scanCharactersFromSet:(NSCharacterSet *)inSet intoString:(NSString **)outValue 181 | { 182 | u_int8_t *P; 183 | for (P = current; P < end && [inSet characterIsMember:*P] == YES; ++P) 184 | ; 185 | 186 | if (P == current) 187 | { 188 | return(NO); 189 | } 190 | 191 | if (outValue) 192 | { 193 | *outValue = [[[NSString alloc] initWithBytes:current length:P - current encoding:NSUTF8StringEncoding] autorelease]; 194 | } 195 | 196 | current = P; 197 | 198 | return(YES); 199 | } 200 | 201 | - (BOOL)scanUpToString:(NSString *)inString intoString:(NSString **)outValue 202 | { 203 | const char *theToken = [inString UTF8String]; 204 | const char *theResult = strnstr((char *)current, theToken, end - current); 205 | if (theResult == NULL) 206 | { 207 | return(NO); 208 | } 209 | 210 | if (outValue) 211 | { 212 | *outValue = [[[NSString alloc] initWithBytes:current length:theResult - (char *)current encoding:NSUTF8StringEncoding] autorelease]; 213 | } 214 | 215 | current = (u_int8_t *)theResult; 216 | 217 | return(YES); 218 | } 219 | 220 | - (BOOL)scanUpToCharactersFromSet:(NSCharacterSet *)inSet intoString:(NSString **)outValue 221 | { 222 | u_int8_t *P; 223 | for (P = current; P < end && [inSet characterIsMember:*P] == NO; ++P) 224 | ; 225 | 226 | if (P == current) 227 | { 228 | return(NO); 229 | } 230 | 231 | if (outValue) 232 | { 233 | *outValue = [[[NSString alloc] initWithBytes:current length:P - current encoding:NSUTF8StringEncoding] autorelease]; 234 | } 235 | 236 | current = P; 237 | 238 | return(YES); 239 | } 240 | 241 | - (BOOL)scanNumber:(NSNumber **)outValue 242 | { 243 | // Replace all of this with a strtod call 244 | NSString *theString = NULL; 245 | if ([self scanCharactersFromSet:doubleCharacters intoString:&theString]) 246 | { 247 | if (outValue) 248 | *outValue = [NSNumber numberWithDouble:[theString doubleValue]]; // TODO dont use doubleValue 249 | return(YES); 250 | } 251 | return(NO); 252 | } 253 | 254 | - (void)skipWhitespace 255 | { 256 | u_int8_t *P; 257 | for (P = current; P < end && (isspace(*P)); ++P) 258 | ; 259 | 260 | current = P; 261 | } 262 | 263 | - (NSString *)remainingString 264 | { 265 | NSData *theRemainingData = [NSData dataWithBytes:current length:end - current]; 266 | NSString *theString = [[[NSString alloc] initWithData:theRemainingData encoding:NSUTF8StringEncoding] autorelease]; 267 | return(theString); 268 | } 269 | 270 | @end 271 | -------------------------------------------------------------------------------- /Classes/GDataXML/GDataXMLNode.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2008 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | // These node, element, and document classes implement a subset of the methods 17 | // provided by NSXML. While NSXML behavior is mimicked as much as possible, 18 | // there are important differences. 19 | // 20 | // The biggest difference is that, since this is based on libxml2, there 21 | // is no retain model for the underlying node data. Rather than copy every 22 | // node obtained from a parse tree (which would have a substantial memory 23 | // impact), we rely on weak references, and it is up to the code that 24 | // created a document to retain it for as long as any 25 | // references rely on nodes inside that document tree. 26 | 27 | 28 | #import 29 | 30 | // libxml includes require that the target Header Search Paths contain 31 | // 32 | // /usr/include/libxml2 33 | // 34 | // and Other Linker Flags contain 35 | // 36 | // -lxml2 37 | 38 | #import 39 | #import 40 | #import 41 | #import 42 | #import 43 | 44 | 45 | #if (MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4) || defined(GDATA_TARGET_NAMESPACE) 46 | // we need NSInteger for the 10.4 SDK, or we're using target namespace macros 47 | #import "GDataDefines.h" 48 | #endif 49 | 50 | #undef _EXTERN 51 | #undef _INITIALIZE_AS 52 | #ifdef GDATAXMLNODE_DEFINE_GLOBALS 53 | #define _EXTERN 54 | #define _INITIALIZE_AS(x) =x 55 | #else 56 | #if defined(__cplusplus) 57 | #define _EXTERN extern "C" 58 | #else 59 | #define _EXTERN extern 60 | #endif 61 | #define _INITIALIZE_AS(x) 62 | #endif 63 | 64 | // when no namespace dictionary is supplied for XPath, the default namespace 65 | // for the evaluated tree is registered with the prefix _def_ns 66 | _EXTERN const char* kGDataXMLXPathDefaultNamespacePrefix _INITIALIZE_AS("_def_ns"); 67 | 68 | // Nomenclature for method names: 69 | // 70 | // Node = GData node 71 | // XMLNode = xmlNodePtr 72 | // 73 | // So, for example: 74 | // + (id)nodeConsumingXMLNode:(xmlNodePtr)theXMLNode; 75 | 76 | @class NSArray, NSDictionary, NSError, NSString, NSURL; 77 | @class GDataXMLElement, GDataXMLDocument; 78 | 79 | enum { 80 | GDataXMLInvalidKind = 0, 81 | GDataXMLDocumentKind, 82 | GDataXMLElementKind, 83 | GDataXMLAttributeKind, 84 | GDataXMLNamespaceKind, 85 | GDataXMLProcessingInstructionKind, 86 | GDataXMLCommentKind, 87 | GDataXMLTextKind, 88 | GDataXMLDTDKind, 89 | GDataXMLEntityDeclarationKind, 90 | GDataXMLAttributeDeclarationKind, 91 | GDataXMLElementDeclarationKind, 92 | GDataXMLNotationDeclarationKind 93 | }; 94 | 95 | typedef NSUInteger GDataXMLNodeKind; 96 | 97 | @interface GDataXMLNode : NSObject { 98 | @protected 99 | // NSXMLNodes can have a namespace URI or prefix even if not part 100 | // of a tree; xmlNodes cannot. When we create nodes apart from 101 | // a tree, we'll store the dangling prefix or URI in the xmlNode's name, 102 | // like 103 | // "prefix:name" 104 | // or 105 | // "{http://uri}:name" 106 | // 107 | // We will fix up the node's namespace and name (and those of any children) 108 | // later when adding the node to a tree with addChild: or addAttribute:. 109 | // See fixUpNamespacesForNode:. 110 | 111 | xmlNodePtr xmlNode_; // may also be an xmlAttrPtr or xmlNsPtr 112 | BOOL shouldFreeXMLNode_; // if yes, xmlNode_ will be free'd in dealloc 113 | 114 | // cached values 115 | NSString *cachedName_; 116 | NSArray *cachedChildren_; 117 | NSArray *cachedAttributes_; 118 | } 119 | 120 | + (GDataXMLElement *)elementWithName:(NSString *)name; 121 | + (GDataXMLElement *)elementWithName:(NSString *)name stringValue:(NSString *)value; 122 | + (GDataXMLElement *)elementWithName:(NSString *)name URI:(NSString *)value; 123 | 124 | + (id)attributeWithName:(NSString *)name stringValue:(NSString *)value; 125 | + (id)attributeWithName:(NSString *)name URI:(NSString *)attributeURI stringValue:(NSString *)value; 126 | 127 | + (id)namespaceWithName:(NSString *)name stringValue:(NSString *)value; 128 | 129 | + (id)textWithStringValue:(NSString *)value; 130 | 131 | - (NSString *)stringValue; 132 | - (void)setStringValue:(NSString *)str; 133 | 134 | - (NSUInteger)childCount; 135 | - (NSArray *)children; 136 | - (GDataXMLNode *)childAtIndex:(unsigned)index; 137 | 138 | - (NSString *)localName; 139 | - (NSString *)name; 140 | - (NSString *)prefix; 141 | - (NSString *)URI; 142 | 143 | - (GDataXMLNodeKind)kind; 144 | 145 | - (NSString *)XMLString; 146 | 147 | + (NSString *)localNameForName:(NSString *)name; 148 | + (NSString *)prefixForName:(NSString *)name; 149 | 150 | // This is the preferred entry point for nodesForXPath. This takes an explicit 151 | // namespace dictionary (keys are prefixes, values are URIs). 152 | - (NSArray *)nodesForXPath:(NSString *)xpath namespaces:(NSDictionary *)namespaces error:(NSError **)error; 153 | 154 | // This implementation of nodesForXPath registers namespaces only from the 155 | // document's root node. _def_ns may be used as a prefix for the default 156 | // namespace, though there's no guarantee that the default namespace will 157 | // be consistenly the same namespace in server responses. 158 | - (NSArray *)nodesForXPath:(NSString *)xpath error:(NSError **)error; 159 | 160 | // access to the underlying libxml node; be sure to release the cached values 161 | // if you change the underlying tree at all 162 | - (xmlNodePtr)XMLNode; 163 | - (void)releaseCachedValues; 164 | 165 | @end 166 | 167 | 168 | @interface GDataXMLElement : GDataXMLNode 169 | 170 | - (id)initWithXMLString:(NSString *)str error:(NSError **)error; 171 | 172 | - (NSArray *)namespaces; 173 | - (void)setNamespaces:(NSArray *)namespaces; 174 | - (void)addNamespace:(GDataXMLNode *)aNamespace; 175 | 176 | // addChild adds a copy of the child node to the element 177 | - (void)addChild:(GDataXMLNode *)child; 178 | - (void)removeChild:(GDataXMLNode *)child; 179 | 180 | - (NSArray *)elementsForName:(NSString *)name; 181 | - (NSArray *)elementsForLocalName:(NSString *)localName URI:(NSString *)URI; 182 | 183 | - (NSArray *)attributes; 184 | - (GDataXMLNode *)attributeForName:(NSString *)name; 185 | - (GDataXMLNode *)attributeForLocalName:(NSString *)name URI:(NSString *)attributeURI; 186 | - (void)addAttribute:(GDataXMLNode *)attribute; 187 | 188 | - (NSString *)resolvePrefixForNamespaceURI:(NSString *)namespaceURI; 189 | 190 | @end 191 | 192 | @interface GDataXMLDocument : NSObject { 193 | @protected 194 | xmlDoc* xmlDoc_; // strong; always free'd in dealloc 195 | } 196 | 197 | - (id)initWithXMLString:(NSString *)str options:(unsigned int)mask error:(NSError **)error; 198 | - (id)initWithData:(NSData *)data options:(unsigned int)mask error:(NSError **)error; 199 | 200 | // initWithRootElement uses a copy of the argument as the new document's root 201 | - (id)initWithRootElement:(GDataXMLElement *)element; 202 | 203 | - (GDataXMLElement *)rootElement; 204 | 205 | - (NSData *)XMLData; 206 | 207 | - (void)setVersion:(NSString *)version; 208 | - (void)setCharacterEncoding:(NSString *)encoding; 209 | 210 | // This is the preferred entry point for nodesForXPath. This takes an explicit 211 | // namespace dictionary (keys are prefixes, values are URIs). 212 | - (NSArray *)nodesForXPath:(NSString *)xpath namespaces:(NSDictionary *)namespaces error:(NSError **)error; 213 | 214 | // This implementation of nodesForXPath registers namespaces only from the 215 | // document's root node. _def_ns may be used as a prefix for the default 216 | // namespace, though there's no guarantee that the default namespace will 217 | // be consistenly the same namespace in server responses. 218 | - (NSArray *)nodesForXPath:(NSString *)xpath error:(NSError **)error; 219 | 220 | - (NSString *)description; 221 | @end 222 | -------------------------------------------------------------------------------- /Classes/WordsViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // WordsViewController.m 3 | // MKDic 4 | // 5 | // Created by stm on 11-6-16. 6 | // Copyright 2011 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import "WordsViewController.h" 10 | #import "GeneralManager.h" 11 | #import "GDataXMLNode.h" 12 | #import "WordNoteDao.h" 13 | 14 | @implementation WordsViewController 15 | 16 | - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil 17 | { 18 | self=[super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 19 | if (self) 20 | { 21 | translates=[[NSMutableArray alloc] init]; 22 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveNotification:) name:kNotificationSearchWorld object:nil]; 23 | } 24 | return self; 25 | } 26 | 27 | - (void)receiveNotification:(NSNotification *)aNotification 28 | { 29 | [self performSelector:@selector(rightMenuItemClick:) withObject:[aNotification object]]; 30 | } 31 | 32 | - (void)loadView 33 | { 34 | [super loadView]; 35 | searchField.delegate=self; 36 | } 37 | 38 | - (void)dealloc 39 | { 40 | [[NSNotificationCenter defaultCenter] removeObserver:self]; 41 | [translates release]; 42 | [super dealloc]; 43 | } 44 | 45 | #pragma mark - 46 | #pragma mark CustomFunc 47 | 48 | - (IBAction)translateBegin:(NSButton *)sender 49 | { 50 | [[GeneralManager shareManager] stopSpeak]; 51 | 52 | NSString *string=[searchField stringValue]; 53 | if ([string length]==0) 54 | { 55 | return; 56 | } 57 | 58 | //此处利用了异步加载 59 | //NSString *urlstring = [NSString stringWithFormat:@"http://dict.cn/ws.php?q=%@",string]; 60 | NSString *urlstring = [NSString stringWithFormat:@"http://fanyi.youdao.com/openapi.do?keyfrom=tanhao&key=881024171&type=data&doctype=xml&version=1.1&q=%@",string]; 61 | NSString *encodedString = (NSString *)CFURLCreateStringByAddingPercentEscapes( kCFAllocatorDefault, (CFStringRef)urlstring, NULL, NULL, kCFStringEncodingUTF8 ); 62 | [[MKServiceManager sharedManager] cancelForDelegate:self]; 63 | [[MKServiceManager sharedManager] downloadWithURL:[NSURL URLWithString:encodedString] delegate:self context:nil]; 64 | 65 | [toTextView setString:@"请等待⋯⋯"]; 66 | CFRelease(encodedString); 67 | return; 68 | } 69 | 70 | - (IBAction)talkClick:(NSButton *)sender 71 | { 72 | [[GeneralManager shareManager] speakWithText:[searchField stringValue]]; 73 | } 74 | 75 | - (IBAction)addNewWord:(NSButton *)sender 76 | { 77 | WordNote *wordNote=[[WordNote alloc] init]; 78 | static int mm=100; 79 | wordNote.row=mm++; 80 | wordNote.word=[searchField stringValue]; 81 | wordNote.translate=[toTextView string]; 82 | wordNote.level=0; 83 | 84 | [[WordNoteDao shareDao] insertWordNote:wordNote]; 85 | [wordNote release]; 86 | } 87 | 88 | - (void)translateEnd 89 | { 90 | while ([translates count]>displayIndex+1) 91 | { 92 | [translates removeLastObject]; 93 | } 94 | 95 | NSString *searchVal=[NSString stringWithString:[searchField stringValue]]; 96 | NSString *translVal=[NSString stringWithString:[toTextView string]]; 97 | NSArray *currentTrans=[[NSArray alloc] initWithObjects:searchVal,translVal,nil]; 98 | [translates addObject:currentTrans]; 99 | [currentTrans release]; 100 | 101 | displayIndex=[translates count]-1; 102 | } 103 | 104 | - (void)undoAction 105 | { 106 | if (displayIndex>0) 107 | { 108 | --displayIndex; 109 | NSArray *currentTrans=[translates objectAtIndex:displayIndex]; 110 | [searchField setStringValue:(NSString *)[currentTrans objectAtIndex:0]]; 111 | [toTextView setString:(NSString *)[currentTrans objectAtIndex:1]]; 112 | } 113 | } 114 | 115 | - (void)redoAction 116 | { 117 | if ([translates count]>displayIndex+1) 118 | { 119 | ++displayIndex; 120 | NSArray *currentTrans=[translates objectAtIndex:displayIndex]; 121 | [searchField setStringValue:(NSString *)[currentTrans objectAtIndex:0]]; 122 | [toTextView setString:(NSString *)[currentTrans objectAtIndex:1]]; 123 | } 124 | } 125 | 126 | 127 | #pragma mark - 128 | #pragma mark MKServiceManagerDelegate 129 | 130 | - (NSString *)readXmlInfo:(NSString *)aString 131 | { 132 | NSMutableString *displayString=[[[NSMutableString alloc] init] autorelease]; 133 | 134 | NSError *error; 135 | //NSStringEncoding encoding=CFStringConvertEncodingToNSStringEncoding(kCFStringEncodingGB_18030_2000); 136 | NSStringEncoding encoding=NSUTF8StringEncoding; 137 | NSData *data=[aString dataUsingEncoding:encoding]; 138 | GDataXMLDocument* document = [[GDataXMLDocument alloc] initWithData:data options:0 error:&error]; 139 | GDataXMLElement *rootNode = [document rootElement]; 140 | 141 | //自动纠错 142 | NSArray *sugg=[rootNode nodesForXPath:@"//dict/sugg" error:&error]; 143 | if ([sugg count]>0) { 144 | [displayString appendFormat:@"您要查找的是不是:\n"]; 145 | for(GDataXMLNode* node in sugg){ 146 | [displayString appendFormat:@"%@ ",[node stringValue]]; 147 | } 148 | } 149 | //读音 150 | NSArray *pron = [rootNode nodesForXPath:@"//basic/phonetic" error:&error]; 151 | if ([pron count]>0) { 152 | [displayString appendFormat:@"读音: %@\n\n",[[pron objectAtIndex:0] stringValue]]; 153 | } 154 | //解释 155 | NSArray *def = [rootNode nodesForXPath:@"//basic/explains/ex" error:&error]; 156 | if ([def count]>0) 157 | { 158 | [displayString appendFormat:@"释义:\n"]; 159 | for (int i=0; i<[def count]; i++) 160 | { 161 | [displayString appendFormat:@"%@\n",[[def objectAtIndex:i] stringValue]]; 162 | } 163 | } 164 | //例句 165 | NSArray *orig = [rootNode nodesForXPath:@"//explain/key" error:&error]; 166 | NSArray *trans= [rootNode nodesForXPath:@"//explain/value/ex" error:&error]; 167 | if ([orig count]>0) { 168 | [displayString appendFormat:@"\n例句:\n"]; 169 | for (int i=0; i<[orig count]; i++) 170 | { 171 | [displayString appendFormat:@"%@\n%@\n",[[orig objectAtIndex:i] stringValue],[[trans objectAtIndex:i] stringValue]]; 172 | } 173 | } 174 | 175 | [document release]; 176 | return displayString; 177 | } 178 | 179 | 180 | - (NSString *)readXmlInfoOld:(NSString *)aString{ 181 | NSMutableString *displayString=[[[NSMutableString alloc] init] autorelease]; 182 | 183 | NSError *error; 184 | //NSStringEncoding encoding=CFStringConvertEncodingToNSStringEncoding(kCFStringEncodingGB_18030_2000); 185 | NSStringEncoding encoding=NSUTF8StringEncoding; 186 | NSData *data=[aString dataUsingEncoding:encoding]; 187 | GDataXMLDocument* document = [[GDataXMLDocument alloc] initWithData:data options:0 error:&error]; 188 | GDataXMLElement *rootNode = [document rootElement]; 189 | 190 | //自动纠错 191 | NSArray *sugg=[rootNode nodesForXPath:@"//dict/sugg" error:&error]; 192 | if ([sugg count]>0) { 193 | [displayString appendFormat:@"您要查找的是不是:\n"]; 194 | for(GDataXMLNode* node in sugg){ 195 | [displayString appendFormat:@"%@ ",[node stringValue]]; 196 | } 197 | } 198 | //读音 199 | NSArray *pron = [rootNode nodesForXPath:@"//dict/pron" error:&error]; 200 | if ([pron count]>0) { 201 | [displayString appendFormat:@"读音: %@\n\n",[[pron objectAtIndex:0] stringValue]]; 202 | } 203 | //解释 204 | NSArray *def = [rootNode nodesForXPath:@"//dict/def" error:&error]; 205 | if ([def count]>0) { 206 | [displayString appendFormat:@"释义:\n%@\n\n",[[def objectAtIndex:0] stringValue]]; 207 | } 208 | //例句 209 | NSArray *orig = [rootNode nodesForXPath:@"//dict/sent/orig" error:&error]; 210 | NSArray *trans= [rootNode nodesForXPath:@"//dict/sent/trans" error:&error]; 211 | if ([orig count]>0) { 212 | [displayString appendFormat:@"例句:\n"]; 213 | for (int i=0; i<[orig count]; i++) { 214 | [displayString appendFormat:@"%@\n%@\n",[[orig objectAtIndex:i] stringValue],[[trans objectAtIndex:i] stringValue]]; 215 | } 216 | } 217 | //替换掉标签 218 | [displayString replaceOccurrencesOfString:@"" withString:@"" options:0 range:NSMakeRange(0, [displayString length])]; 219 | [displayString replaceOccurrencesOfString:@"" withString:@"" options:0 range:NSMakeRange(0, [displayString length])]; 220 | 221 | [document release]; 222 | return displayString; 223 | } 224 | 225 | - (void)serviceFinish:(MKServiceManager *)webService didReceiveData:(NSData *)data context:(id)context 226 | { 227 | //NSStringEncoding encoding=CFStringConvertEncodingToNSStringEncoding(kCFStringEncodingGB_18030_2000); 228 | NSStringEncoding encoding=NSUTF8StringEncoding; 229 | NSString *receiveString = [[NSString alloc] initWithData:data encoding:encoding]; 230 | if (receiveString==nil) 231 | { 232 | [toTextView setString:@"No Define !"]; 233 | return; 234 | } 235 | 236 | NSString *displayString=[self readXmlInfo:receiveString]; 237 | [toTextView setString:displayString]; 238 | 239 | if ([displayString length] == 0) 240 | { 241 | [toTextView setString:@"查无此单词!"]; 242 | } 243 | 244 | [receiveString release]; 245 | [self translateEnd]; 246 | } 247 | 248 | - (void)servicFail:(MKServiceManager *)webService didFailWithError:(NSError *)error context:(id)context 249 | { 250 | [toTextView setString:[error description]]; 251 | } 252 | 253 | #pragma mark - 254 | #pragma mark NSControlTextEditingDelegate 255 | 256 | - (BOOL)control:(NSControl *)control textShouldEndEditing:(NSText *)fieldEditor 257 | { 258 | [self translateBegin:nil]; 259 | return YES; 260 | } 261 | 262 | #pragma mark - 263 | #pragma mark CustomViewControllerProtocol 264 | 265 | - (void)quickTranslateWithString:(NSString *)str 266 | { 267 | [searchField setStringValue:str]; 268 | [self translateBegin:nil]; 269 | } 270 | 271 | - (void)setFirstResponder 272 | { 273 | dispatch_async(dispatch_get_main_queue(), ^{ 274 | [self.view.window makeFirstResponder:searchField]; 275 | }); 276 | //[searchField becomeFirstResponder]; 277 | } 278 | 279 | - (void)changeFont:(NSFont *)aFont 280 | { 281 | [toTextView setFont:aFont]; 282 | } 283 | 284 | #pragma mark - 285 | #pragma mark CustomerTextViewDelegate 286 | 287 | - (void)rightMenuItemClick:(NSString *)aText 288 | { 289 | [searchField setStringValue:aText]; 290 | [self translateBegin:nil]; 291 | } 292 | 293 | @end 294 | -------------------------------------------------------------------------------- /Classes/TouchJSON/JSON/CJSONScanner.m: -------------------------------------------------------------------------------- 1 | // 2 | // CJSONScanner.m 3 | // TouchJSON 4 | // 5 | // Created by Jonathan Wight on 12/07/2005. 6 | // Copyright (c) 2005 Jonathan Wight 7 | // 8 | // Permission is hereby granted, free of charge, to any person 9 | // obtaining a copy of this software and associated documentation 10 | // files (the "Software"), to deal in the Software without 11 | // restriction, including without limitation the rights to use, 12 | // copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the 14 | // Software is furnished to do so, subject to the following 15 | // conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 22 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 24 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 25 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 26 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 27 | // OTHER DEALINGS IN THE SOFTWARE. 28 | // 29 | 30 | #import "CJSONScanner.h" 31 | 32 | #import "NSCharacterSet_Extensions.h" 33 | #import "CDataScanner_Extensions.h" 34 | 35 | #if !defined(TREAT_COMMENTS_AS_WHITESPACE) 36 | #define TREAT_COMMENTS_AS_WHITESPACE 0 37 | #endif // !defined(TREAT_COMMENTS_AS_WHITESPACE) 38 | 39 | NSString *const kJSONScannerErrorDomain = @"CJSONScannerErrorDomain"; 40 | 41 | inline static int HexToInt(char inCharacter) 42 | { 43 | int theValues[] = { 0x0 /* 48 '0' */, 0x1 /* 49 '1' */, 0x2 /* 50 '2' */, 0x3 /* 51 '3' */, 0x4 /* 52 '4' */, 0x5 /* 53 '5' */, 0x6 /* 54 '6' */, 0x7 /* 55 '7' */, 0x8 /* 56 '8' */, 0x9 /* 57 '9' */, -1 /* 58 ':' */, -1 /* 59 ';' */, -1 /* 60 '<' */, -1 /* 61 '=' */, -1 /* 62 '>' */, -1 /* 63 '?' */, -1 /* 64 '@' */, 0xa /* 65 'A' */, 0xb /* 66 'B' */, 0xc /* 67 'C' */, 0xd /* 68 'D' */, 0xe /* 69 'E' */, 0xf /* 70 'F' */, -1 /* 71 'G' */, -1 /* 72 'H' */, -1 /* 73 'I' */, -1 /* 74 'J' */, -1 /* 75 'K' */, -1 /* 76 'L' */, -1 /* 77 'M' */, -1 /* 78 'N' */, -1 /* 79 'O' */, -1 /* 80 'P' */, -1 /* 81 'Q' */, -1 /* 82 'R' */, -1 /* 83 'S' */, -1 /* 84 'T' */, -1 /* 85 'U' */, -1 /* 86 'V' */, -1 /* 87 'W' */, -1 /* 88 'X' */, -1 /* 89 'Y' */, -1 /* 90 'Z' */, -1 /* 91 '[' */, -1 /* 92 '\' */, -1 /* 93 ']' */, -1 /* 94 '^' */, -1 /* 95 '_' */, -1 /* 96 '`' */, 0xa /* 97 'a' */, 0xb /* 98 'b' */, 0xc /* 99 'c' */, 0xd /* 100 'd' */, 0xe /* 101 'e' */, 0xf /* 102 'f' */, }; 44 | if (inCharacter >= '0' && inCharacter <= 'f') 45 | return(theValues[inCharacter - '0']); 46 | else 47 | return(-1); 48 | } 49 | 50 | @interface CJSONScanner () 51 | - (BOOL)scanNotQuoteCharactersIntoString:(NSString **)outValue; 52 | @end 53 | 54 | #pragma mark - 55 | 56 | @implementation CJSONScanner 57 | 58 | - (id)init 59 | { 60 | if ((self = [super init]) != nil) 61 | { 62 | } 63 | return(self); 64 | } 65 | 66 | - (void)dealloc 67 | { 68 | // 69 | [super dealloc]; 70 | } 71 | 72 | #pragma mark - 73 | 74 | - (void)setData:(NSData *)inData 75 | { 76 | NSData *theData = inData; 77 | if (theData && theData.length >= 4) 78 | { 79 | // This code is lame, but it works. Because the first character of any JSON string will always be a (ascii) control character we can work out the Unicode encoding by the bit pattern. See section 3 of http://www.ietf.org/rfc/rfc4627.txt 80 | const char *theChars = theData.bytes; 81 | NSStringEncoding theEncoding = NSUTF8StringEncoding; 82 | if (theChars[0] != 0 && theChars[1] == 0) 83 | { 84 | if (theChars[2] != 0 && theChars[3] == 0) 85 | theEncoding = NSUTF16LittleEndianStringEncoding; 86 | else if (theChars[2] == 0 && theChars[3] == 0) 87 | theEncoding = NSUTF32LittleEndianStringEncoding; 88 | } 89 | else if (theChars[0] == 0 && theChars[2] == 0 && theChars[3] != 0) 90 | { 91 | if (theChars[1] == 0) 92 | theEncoding = NSUTF32BigEndianStringEncoding; 93 | else if (theChars[1] != 0) 94 | theEncoding = NSUTF16BigEndianStringEncoding; 95 | } 96 | 97 | if (theEncoding != NSUTF8StringEncoding) 98 | { 99 | NSString *theString = [[NSString alloc] initWithData:theData encoding:theEncoding]; 100 | theData = [theString dataUsingEncoding:NSUTF8StringEncoding]; 101 | [theString release]; 102 | } 103 | } 104 | [super setData:theData]; 105 | } 106 | 107 | #pragma mark - 108 | 109 | - (BOOL)scanJSONObject:(id *)outObject error:(NSError **)outError 110 | { 111 | [self skipWhitespace]; 112 | 113 | id theObject = NULL; 114 | 115 | const unichar C = [self currentCharacter]; 116 | switch (C) 117 | { 118 | case 't': 119 | if ([self scanUTF8String:"true" intoString:NULL]) 120 | { 121 | theObject = [NSNumber numberWithBool:YES]; 122 | } 123 | break; 124 | case 'f': 125 | if ([self scanUTF8String:"false" intoString:NULL]) 126 | { 127 | theObject = [NSNumber numberWithBool:NO]; 128 | } 129 | break; 130 | case 'n': 131 | if ([self scanUTF8String:"null" intoString:NULL]) 132 | { 133 | theObject = [NSNull null]; 134 | } 135 | break; 136 | case '\"': 137 | case '\'': 138 | [self scanJSONStringConstant:&theObject error:outError]; 139 | break; 140 | case '0': 141 | case '1': 142 | case '2': 143 | case '3': 144 | case '4': 145 | case '5': 146 | case '6': 147 | case '7': 148 | case '8': 149 | case '9': 150 | case '-': 151 | [self scanJSONNumberConstant:&theObject error:outError]; 152 | break; 153 | case '{': 154 | [self scanJSONDictionary:&theObject error:outError]; 155 | break; 156 | case '[': 157 | [self scanJSONArray:&theObject error:outError]; 158 | break; 159 | default: 160 | 161 | break; 162 | } 163 | 164 | if (outObject != NULL) 165 | *outObject = theObject; 166 | return(YES); 167 | } 168 | 169 | - (BOOL)scanJSONDictionary:(NSDictionary **)outDictionary error:(NSError **)outError 170 | { 171 | NSUInteger theScanLocation = [self scanLocation]; 172 | 173 | if ([self scanCharacter:'{'] == NO) 174 | { 175 | if (outError) 176 | { 177 | NSDictionary *theUserInfo = [NSDictionary dictionaryWithObjectsAndKeys: 178 | @"Could not scan dictionary. Dictionary that does not start with '{' character.", NSLocalizedDescriptionKey, 179 | NULL]; 180 | *outError = [NSError errorWithDomain:kJSONScannerErrorDomain code:-1 userInfo:theUserInfo]; 181 | } 182 | return(NO); 183 | } 184 | 185 | NSMutableDictionary *theDictionary = [[NSMutableDictionary alloc] init]; 186 | 187 | while ([self currentCharacter] != '}') 188 | { 189 | [self skipWhitespace]; 190 | 191 | if ([self currentCharacter] == '}') 192 | break; 193 | 194 | NSString *theKey = NULL; 195 | if ([self scanJSONStringConstant:&theKey error:outError] == NO) 196 | { 197 | [self setScanLocation:theScanLocation]; 198 | if (outError) 199 | { 200 | NSDictionary *theUserInfo = [NSDictionary dictionaryWithObjectsAndKeys: 201 | @"Could not scan dictionary. Failed to scan a key.", NSLocalizedDescriptionKey, 202 | NULL]; 203 | *outError = [NSError errorWithDomain:kJSONScannerErrorDomain code:-2 userInfo:theUserInfo]; 204 | } 205 | [theDictionary release]; 206 | return(NO); 207 | } 208 | 209 | [self skipWhitespace]; 210 | 211 | if ([self scanCharacter:':'] == NO) 212 | { 213 | [self setScanLocation:theScanLocation]; 214 | if (outError) 215 | { 216 | NSDictionary *theUserInfo = [NSDictionary dictionaryWithObjectsAndKeys: 217 | @"Could not scan dictionary. Key was not terminated with a ':' character.", NSLocalizedDescriptionKey, 218 | NULL]; 219 | *outError = [NSError errorWithDomain:kJSONScannerErrorDomain code:-3 userInfo:theUserInfo]; 220 | } 221 | [theDictionary release]; 222 | return(NO); 223 | } 224 | 225 | id theValue = NULL; 226 | if ([self scanJSONObject:&theValue error:outError] == NO) 227 | { 228 | [self setScanLocation:theScanLocation]; 229 | if (outError) 230 | { 231 | NSDictionary *theUserInfo = [NSDictionary dictionaryWithObjectsAndKeys: 232 | @"Could not scan dictionary. Failed to scan a value.", NSLocalizedDescriptionKey, 233 | NULL]; 234 | *outError = [NSError errorWithDomain:kJSONScannerErrorDomain code:-4 userInfo:theUserInfo]; 235 | } 236 | [theDictionary release]; 237 | return(NO); 238 | } 239 | 240 | [theDictionary setValue:theValue forKey:theKey]; 241 | 242 | [self skipWhitespace]; 243 | if ([self scanCharacter:','] == NO) 244 | { 245 | if ([self currentCharacter] != '}') 246 | { 247 | [self setScanLocation:theScanLocation]; 248 | if (outError) 249 | { 250 | NSDictionary *theUserInfo = [NSDictionary dictionaryWithObjectsAndKeys: 251 | @"Could not scan dictionary. Key value pairs not delimited with a ',' character.", NSLocalizedDescriptionKey, 252 | NULL]; 253 | *outError = [NSError errorWithDomain:kJSONScannerErrorDomain code:-5 userInfo:theUserInfo]; 254 | } 255 | [theDictionary release]; 256 | return(NO); 257 | } 258 | break; 259 | } 260 | else 261 | { 262 | [self skipWhitespace]; 263 | if ([self currentCharacter] == '}') 264 | break; 265 | } 266 | } 267 | 268 | if ([self scanCharacter:'}'] == NO) 269 | { 270 | [self setScanLocation:theScanLocation]; 271 | if (outError) 272 | { 273 | NSDictionary *theUserInfo = [NSDictionary dictionaryWithObjectsAndKeys: 274 | @"Could not scan dictionary. Dictionary not terminated by a '}' character.", NSLocalizedDescriptionKey, 275 | NULL]; 276 | *outError = [NSError errorWithDomain:kJSONScannerErrorDomain code:-6 userInfo:theUserInfo]; 277 | } 278 | [theDictionary release]; 279 | return(NO); 280 | } 281 | 282 | if (outDictionary != NULL) 283 | *outDictionary = [[theDictionary copy] autorelease]; 284 | 285 | [theDictionary release]; 286 | 287 | return(YES); 288 | } 289 | 290 | - (BOOL)scanJSONArray:(NSArray **)outArray error:(NSError **)outError 291 | { 292 | NSUInteger theScanLocation = [self scanLocation]; 293 | 294 | if ([self scanCharacter:'['] == NO) 295 | { 296 | if (outError) 297 | { 298 | NSDictionary *theUserInfo = [NSDictionary dictionaryWithObjectsAndKeys: 299 | @"Could not scan array. Array not started by a '{' character.", NSLocalizedDescriptionKey, 300 | NULL]; 301 | *outError = [NSError errorWithDomain:kJSONScannerErrorDomain code:-7 userInfo:theUserInfo]; 302 | } 303 | return(NO); 304 | } 305 | 306 | NSMutableArray *theArray = [[NSMutableArray alloc] init]; 307 | 308 | [self skipWhitespace]; 309 | while ([self currentCharacter] != ']') 310 | { 311 | NSString *theValue = NULL; 312 | if ([self scanJSONObject:&theValue error:outError] == NO) 313 | { 314 | [self setScanLocation:theScanLocation]; 315 | if (outError) 316 | { 317 | NSDictionary *theUserInfo = [NSDictionary dictionaryWithObjectsAndKeys: 318 | @"Could not scan array. Could not scan a value.", NSLocalizedDescriptionKey, 319 | NULL]; 320 | *outError = [NSError errorWithDomain:kJSONScannerErrorDomain code:-8 userInfo:theUserInfo]; 321 | } 322 | [theArray release]; 323 | return(NO); 324 | } 325 | 326 | [theArray addObject:theValue]; 327 | 328 | [self skipWhitespace]; 329 | if ([self scanCharacter:','] == NO) 330 | { 331 | [self skipWhitespace]; 332 | if ([self currentCharacter] != ']') 333 | { 334 | [self setScanLocation:theScanLocation]; 335 | if (outError) 336 | { 337 | NSDictionary *theUserInfo = [NSDictionary dictionaryWithObjectsAndKeys: 338 | @"Could not scan array. Array not terminated by a ']' character.", NSLocalizedDescriptionKey, 339 | NULL]; 340 | *outError = [NSError errorWithDomain:kJSONScannerErrorDomain code:-9 userInfo:theUserInfo]; 341 | } 342 | [theArray release]; 343 | return(NO); 344 | } 345 | 346 | break; 347 | } 348 | [self skipWhitespace]; 349 | } 350 | 351 | [self skipWhitespace]; 352 | 353 | if ([self scanCharacter:']'] == NO) 354 | { 355 | [self setScanLocation:theScanLocation]; 356 | if (outError) 357 | { 358 | NSDictionary *theUserInfo = [NSDictionary dictionaryWithObjectsAndKeys: 359 | @"Could not scan array. Array not terminated by a ']' character.", NSLocalizedDescriptionKey, 360 | NULL]; 361 | *outError = [NSError errorWithDomain:kJSONScannerErrorDomain code:-10 userInfo:theUserInfo]; 362 | } 363 | [theArray release]; 364 | return(NO); 365 | } 366 | 367 | if (outArray != NULL) 368 | *outArray = [[theArray copy] autorelease]; 369 | 370 | [theArray release]; 371 | 372 | return(YES); 373 | } 374 | 375 | - (BOOL)scanJSONStringConstant:(NSString **)outStringConstant error:(NSError **)outError 376 | { 377 | NSUInteger theScanLocation = [self scanLocation]; 378 | 379 | [self skipWhitespace]; // TODO - i want to remove this method. But breaks unit tests. 380 | 381 | NSMutableString *theString = [[NSMutableString alloc] init]; 382 | 383 | if ([self scanCharacter:'"'] == NO) 384 | { 385 | [self setScanLocation:theScanLocation]; 386 | if (outError) 387 | { 388 | NSDictionary *theUserInfo = [NSDictionary dictionaryWithObjectsAndKeys: 389 | @"Could not scan string constant. String not started by a '\"' character.", NSLocalizedDescriptionKey, 390 | NULL]; 391 | *outError = [NSError errorWithDomain:kJSONScannerErrorDomain code:-11 userInfo:theUserInfo]; 392 | } 393 | [theString release]; 394 | return(NO); 395 | } 396 | 397 | while ([self scanCharacter:'"'] == NO) 398 | { 399 | NSString *theStringChunk = NULL; 400 | if ([self scanNotQuoteCharactersIntoString:&theStringChunk]) 401 | { 402 | [theString appendString:theStringChunk]; 403 | } 404 | 405 | if ([self scanCharacter:'\\'] == YES) 406 | { 407 | unichar theCharacter = [self scanCharacter]; 408 | switch (theCharacter) 409 | { 410 | case '"': 411 | case '\\': 412 | case '/': 413 | break; 414 | case 'b': 415 | theCharacter = '\b'; 416 | break; 417 | case 'f': 418 | theCharacter = '\f'; 419 | break; 420 | case 'n': 421 | theCharacter = '\n'; 422 | break; 423 | case 'r': 424 | theCharacter = '\r'; 425 | break; 426 | case 't': 427 | theCharacter = '\t'; 428 | break; 429 | case 'u': 430 | { 431 | theCharacter = 0; 432 | 433 | int theShift; 434 | for (theShift = 12; theShift >= 0; theShift -= 4) 435 | { 436 | const int theDigit = HexToInt([self scanCharacter]); 437 | if (theDigit == -1) 438 | { 439 | [self setScanLocation:theScanLocation]; 440 | if (outError) 441 | { 442 | NSDictionary *theUserInfo = [NSDictionary dictionaryWithObjectsAndKeys: 443 | @"Could not scan string constant. Unicode character could not be decoded.", NSLocalizedDescriptionKey, 444 | NULL]; 445 | *outError = [NSError errorWithDomain:kJSONScannerErrorDomain code:-12 userInfo:theUserInfo]; 446 | } 447 | [theString release]; 448 | return(NO); 449 | } 450 | theCharacter |= (theDigit << theShift); 451 | } 452 | } 453 | break; 454 | default: 455 | { 456 | [self setScanLocation:theScanLocation]; 457 | if (outError) 458 | { 459 | NSDictionary *theUserInfo = [NSDictionary dictionaryWithObjectsAndKeys: 460 | @"Could not scan string constant. Unknown escape code.", NSLocalizedDescriptionKey, 461 | NULL]; 462 | *outError = [NSError errorWithDomain:kJSONScannerErrorDomain code:-13 userInfo:theUserInfo]; 463 | } 464 | [theString release]; 465 | return(NO); 466 | } 467 | break; 468 | } 469 | CFStringAppendCharacters((CFMutableStringRef)theString, &theCharacter, 1); 470 | } 471 | } 472 | 473 | if (outStringConstant != NULL) 474 | *outStringConstant = [[theString copy] autorelease]; 475 | 476 | [theString release]; 477 | 478 | return(YES); 479 | } 480 | 481 | - (BOOL)scanJSONNumberConstant:(NSNumber **)outNumberConstant error:(NSError **)outError 482 | { 483 | NSNumber *theNumber = NULL; 484 | if ([self scanNumber:&theNumber] == YES) 485 | { 486 | if (outNumberConstant != NULL) 487 | *outNumberConstant = theNumber; 488 | return(YES); 489 | } 490 | else 491 | { 492 | if (outError) 493 | { 494 | NSDictionary *theUserInfo = [NSDictionary dictionaryWithObjectsAndKeys: 495 | @"Could not scan number constant.", NSLocalizedDescriptionKey, 496 | NULL]; 497 | *outError = [NSError errorWithDomain:kJSONScannerErrorDomain code:-14 userInfo:theUserInfo]; 498 | } 499 | return(NO); 500 | } 501 | } 502 | 503 | #if TREAT_COMMENTS_AS_WHITESPACE 504 | - (void)skipWhitespace 505 | { 506 | [super skipWhitespace]; 507 | [self scanCStyleComment:NULL]; 508 | [self scanCPlusPlusStyleComment:NULL]; 509 | [super skipWhitespace]; 510 | } 511 | #endif // TREAT_COMMENTS_AS_WHITESPACE 512 | 513 | #pragma mark - 514 | 515 | - (BOOL)scanNotQuoteCharactersIntoString:(NSString **)outValue 516 | { 517 | u_int8_t *P; 518 | for (P = current; P < end && *P != '\"' && *P != '\\'; ++P) 519 | ; 520 | 521 | if (P == current) 522 | { 523 | return(NO); 524 | } 525 | 526 | if (outValue) 527 | { 528 | *outValue = [[[NSString alloc] initWithBytes:current length:P - current encoding:NSUTF8StringEncoding] autorelease]; 529 | } 530 | 531 | current = P; 532 | 533 | return(YES); 534 | } 535 | 536 | @end 537 | -------------------------------------------------------------------------------- /xibs/MainViewController.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 1070 5 | 11E53 6 | 2182 7 | 1138.47 8 | 569.00 9 | 10 | com.apple.InterfaceBuilder.CocoaPlugin 11 | 2182 12 | 13 | 14 | YES 15 | NSCustomView 16 | NSSegmentedCell 17 | NSButton 18 | NSButtonCell 19 | NSCustomObject 20 | NSSegmentedControl 21 | 22 | 23 | YES 24 | com.apple.InterfaceBuilder.CocoaPlugin 25 | 26 | 27 | PluginDependencyRecalculationVersion 28 | 29 | 30 | 31 | YES 32 | 33 | MainViewController 34 | 35 | 36 | FirstResponder 37 | 38 | 39 | NSApplication 40 | 41 | 42 | 43 | 286 44 | 45 | YES 46 | 47 | 48 | 268 49 | {{19, 5}, {341, 32}} 50 | 51 | 52 | 53 | _NS:9 54 | YES 55 | 56 | 67239424 57 | 134217728 58 | Copyright © 1987-2012 TanHao. All Rights Reserved 59 | 60 | LucidaGrande 61 | 13 62 | 1044 63 | 64 | _NS:9 65 | 66 | -939376385 67 | 129 68 | 69 | 70 | 200 71 | 25 72 | 73 | 74 | 75 | 76 | 301 77 | {{17, 341}, {71, 20}} 78 | 79 | 80 | 81 | YES 82 | 83 | 67239424 84 | 0 85 | 86 | LucidaGrande 87 | 12 88 | 16 89 | 90 | 91 | 92 | YES 93 | 94 | 32 95 | 96 | NSImage 97 | NSGoLeftTemplate 98 | 99 | 0 100 | 101 | 102 | 32 103 | 104 | NSImage 105 | NSGoRightTemplate 106 | 107 | 1 108 | 0 109 | 110 | 111 | 1 112 | 2 113 | 3 114 | 115 | 116 | 117 | 118 | 289 119 | {{376, 6}, {77, 24}} 120 | 121 | 122 | 123 | YES 124 | 125 | 67239424 126 | 0 127 | 128 | LucidaGrande 129 | 13 130 | 16 131 | 132 | 133 | 134 | YES 135 | 136 | 137 | NSImage 138 | small_A 139 | 140 | 141 | 0 142 | 143 | 144 | 145 | NSImage 146 | big_A 147 | 148 | 149 | 1 150 | 0 151 | 152 | 153 | 2 154 | 1 155 | 156 | 157 | 158 | 159 | 301 160 | {{316, 337}, {146, 24}} 161 | 162 | 163 | 164 | YES 165 | 166 | 67239424 167 | 0 168 | 169 | 170 | 171 | YES 172 | 173 | 词典 174 | 0 175 | 176 | 177 | 翻译 178 | 1 179 | 0 180 | 181 | 182 | 学习 183 | YES 184 | 0 185 | 186 | 187 | 2 188 | 1 189 | 190 | 191 | 192 | {480, 360} 193 | 194 | 195 | 196 | NSView 197 | 198 | 199 | 200 | 201 | YES 202 | 203 | 204 | view 205 | 206 | 207 | 208 | 2 209 | 210 | 211 | 212 | segmentClick: 213 | 214 | 215 | 216 | 17 217 | 218 | 219 | 220 | segmentedControl 221 | 222 | 223 | 224 | 18 225 | 226 | 227 | 228 | fontChangeClick: 229 | 230 | 231 | 232 | 29 233 | 234 | 235 | 236 | undoClick: 237 | 238 | 239 | 240 | 32 241 | 242 | 243 | 244 | undoSegmentControl 245 | 246 | 247 | 248 | 33 249 | 250 | 251 | 252 | supportClick: 253 | 254 | 255 | 256 | 36 257 | 258 | 259 | 260 | 261 | YES 262 | 263 | 0 264 | 265 | YES 266 | 267 | 268 | 269 | 270 | 271 | -2 272 | 273 | 274 | File's Owner 275 | 276 | 277 | -1 278 | 279 | 280 | First Responder 281 | 282 | 283 | -3 284 | 285 | 286 | Application 287 | 288 | 289 | 1 290 | 291 | 292 | YES 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 15 302 | 303 | 304 | YES 305 | 306 | 307 | 308 | 309 | 310 | 16 311 | 312 | 313 | 314 | 315 | 19 316 | 317 | 318 | YES 319 | 320 | 321 | 322 | 323 | 324 | 20 325 | 326 | 327 | 328 | 329 | 30 330 | 331 | 332 | YES 333 | 334 | 335 | 336 | 337 | 338 | 31 339 | 340 | 341 | 342 | 343 | 34 344 | 345 | 346 | YES 347 | 348 | 349 | 350 | 351 | 352 | 35 353 | 354 | 355 | 356 | 357 | 358 | 359 | YES 360 | 361 | YES 362 | -1.IBPluginDependency 363 | -2.IBPluginDependency 364 | -3.IBPluginDependency 365 | 1.IBPluginDependency 366 | 15.IBPluginDependency 367 | 16.IBPluginDependency 368 | 19.IBPluginDependency 369 | 20.IBPluginDependency 370 | 20.IBSegmentedControlInspectorSelectedSegmentMetadataKey 371 | 30.IBPluginDependency 372 | 31.IBNSSegmentedControlInspectorSelectedSegmentMetadataKey 373 | 31.IBPluginDependency 374 | 31.IBSegmentedControlInspectorSelectedSegmentMetadataKey 375 | 34.CustomClassName 376 | 34.IBPluginDependency 377 | 35.IBPluginDependency 378 | 379 | 380 | YES 381 | com.apple.InterfaceBuilder.CocoaPlugin 382 | com.apple.InterfaceBuilder.CocoaPlugin 383 | com.apple.InterfaceBuilder.CocoaPlugin 384 | com.apple.InterfaceBuilder.CocoaPlugin 385 | com.apple.InterfaceBuilder.CocoaPlugin 386 | com.apple.InterfaceBuilder.CocoaPlugin 387 | com.apple.InterfaceBuilder.CocoaPlugin 388 | com.apple.InterfaceBuilder.CocoaPlugin 389 | 390 | com.apple.InterfaceBuilder.CocoaPlugin 391 | 392 | com.apple.InterfaceBuilder.CocoaPlugin 393 | 394 | THButton 395 | com.apple.InterfaceBuilder.CocoaPlugin 396 | com.apple.InterfaceBuilder.CocoaPlugin 397 | 398 | 399 | 400 | YES 401 | 402 | 403 | 404 | 405 | 406 | YES 407 | 408 | 409 | 410 | 411 | 36 412 | 413 | 414 | 415 | YES 416 | 417 | MainViewController 418 | NSViewController 419 | 420 | YES 421 | 422 | YES 423 | fontChangeClick: 424 | segmentClick: 425 | supportClick: 426 | undoClick: 427 | 428 | 429 | YES 430 | NSSegmentedControl 431 | NSSegmentedControl 432 | id 433 | NSSegmentedControl 434 | 435 | 436 | 437 | YES 438 | 439 | YES 440 | fontChangeClick: 441 | segmentClick: 442 | supportClick: 443 | undoClick: 444 | 445 | 446 | YES 447 | 448 | fontChangeClick: 449 | NSSegmentedControl 450 | 451 | 452 | segmentClick: 453 | NSSegmentedControl 454 | 455 | 456 | supportClick: 457 | id 458 | 459 | 460 | undoClick: 461 | NSSegmentedControl 462 | 463 | 464 | 465 | 466 | YES 467 | 468 | YES 469 | segmentedControl 470 | undoSegmentControl 471 | 472 | 473 | YES 474 | NSSegmentedControl 475 | NSSegmentedControl 476 | 477 | 478 | 479 | YES 480 | 481 | YES 482 | segmentedControl 483 | undoSegmentControl 484 | 485 | 486 | YES 487 | 488 | segmentedControl 489 | NSSegmentedControl 490 | 491 | 492 | undoSegmentControl 493 | NSSegmentedControl 494 | 495 | 496 | 497 | 498 | IBProjectSource 499 | ./Classes/MainViewController.h 500 | 501 | 502 | 503 | THButton 504 | NSButton 505 | 506 | IBProjectSource 507 | ./Classes/THButton.h 508 | 509 | 510 | 511 | 512 | 0 513 | IBCocoaFramework 514 | 515 | com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3 516 | 517 | 518 | YES 519 | 3 520 | 521 | YES 522 | 523 | YES 524 | NSGoLeftTemplate 525 | NSGoRightTemplate 526 | big_A 527 | small_A 528 | 529 | 530 | YES 531 | {9, 9} 532 | {9, 9} 533 | {100, 100} 534 | {100, 100} 535 | 536 | 537 | 538 | 539 | -------------------------------------------------------------------------------- /MKDic.xcodeproj/tanhao.pbxuser: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | 089C165DFE840E0CC02AAC07 /* English */ = { 4 | uiCtxt = { 5 | sepNavIntBoundsRect = "{{0, 0}, {830, 594}}"; 6 | sepNavSelRange = "{0, 0}"; 7 | sepNavVisRange = "{0, 45}"; 8 | }; 9 | }; 10 | 29B97313FDCFA39411CA2CEA /* Project object */ = { 11 | activeBuildConfigurationName = Debug; 12 | activeExecutable = B807A63913AA25D400BE33A4 /* MKDic */; 13 | activeTarget = 8D1107260486CEB800E47090 /* MKDic */; 14 | addToTargets = ( 15 | 8D1107260486CEB800E47090 /* MKDic */, 16 | ); 17 | breakpoints = ( 18 | ); 19 | codeSenseManager = B807A64B13AA25D900BE33A4 /* Code sense */; 20 | executables = ( 21 | B807A63913AA25D400BE33A4 /* MKDic */, 22 | ); 23 | perUserDictionary = { 24 | PBXConfiguration.PBXFileTableDataSource3.PBXFileTableDataSource = { 25 | PBXFileTableDataSourceColumnSortingDirectionKey = "-1"; 26 | PBXFileTableDataSourceColumnSortingKey = PBXFileDataSource_Filename_ColumnID; 27 | PBXFileTableDataSourceColumnWidthsKey = ( 28 | 20, 29 | 823, 30 | 20, 31 | 48, 32 | 43, 33 | 43, 34 | 20, 35 | ); 36 | PBXFileTableDataSourceColumnsKey = ( 37 | PBXFileDataSource_FiletypeID, 38 | PBXFileDataSource_Filename_ColumnID, 39 | PBXFileDataSource_Built_ColumnID, 40 | PBXFileDataSource_ObjectSize_ColumnID, 41 | PBXFileDataSource_Errors_ColumnID, 42 | PBXFileDataSource_Warnings_ColumnID, 43 | PBXFileDataSource_Target_ColumnID, 44 | ); 45 | }; 46 | PBXConfiguration.PBXTargetDataSource.PBXTargetDataSource = { 47 | PBXFileTableDataSourceColumnSortingDirectionKey = "-1"; 48 | PBXFileTableDataSourceColumnSortingKey = PBXFileDataSource_Filename_ColumnID; 49 | PBXFileTableDataSourceColumnWidthsKey = ( 50 | 20, 51 | 612, 52 | 60, 53 | 20, 54 | 48.16259765625, 55 | 43, 56 | 43, 57 | ); 58 | PBXFileTableDataSourceColumnsKey = ( 59 | PBXFileDataSource_FiletypeID, 60 | PBXFileDataSource_Filename_ColumnID, 61 | PBXTargetDataSource_PrimaryAttribute, 62 | PBXFileDataSource_Built_ColumnID, 63 | PBXFileDataSource_ObjectSize_ColumnID, 64 | PBXFileDataSource_Errors_ColumnID, 65 | PBXFileDataSource_Warnings_ColumnID, 66 | ); 67 | }; 68 | PBXPerProjectTemplateStateSaveDate = 330355820; 69 | PBXWorkspaceStateSaveDate = 330355820; 70 | }; 71 | perUserProjectItems = { 72 | B807A69A13AA3C8100BE33A4 /* PBXTextBookmark */ = B807A69A13AA3C8100BE33A4 /* PBXTextBookmark */; 73 | B807A69D13AA3C8100BE33A4 /* PBXTextBookmark */ = B807A69D13AA3C8100BE33A4 /* PBXTextBookmark */; 74 | B807A6C513AA3E4500BE33A4 /* PBXTextBookmark */ = B807A6C513AA3E4500BE33A4 /* PBXTextBookmark */; 75 | B807A70513AA4C9F00BE33A4 /* PBXTextBookmark */ = B807A70513AA4C9F00BE33A4 /* PBXTextBookmark */; 76 | B807A72913AA4F7100BE33A4 /* PBXTextBookmark */ = B807A72913AA4F7100BE33A4 /* PBXTextBookmark */; 77 | B807A76413AA59EC00BE33A4 /* PBXBookmark */ = B807A76413AA59EC00BE33A4 /* PBXBookmark */; 78 | B807A76513AA59EC00BE33A4 /* PBXTextBookmark */ = B807A76513AA59EC00BE33A4 /* PBXTextBookmark */; 79 | B807A76F13AA5A4D00BE33A4 /* PlistBookmark */ = B807A76F13AA5A4D00BE33A4 /* PlistBookmark */; 80 | B841BD2D13ACB3CD00F3B806 /* PBXTextBookmark */ = B841BD2D13ACB3CD00F3B806 /* PBXTextBookmark */; 81 | B841BD7F13ACE3D100F3B806 /* PBXTextBookmark */ = B841BD7F13ACE3D100F3B806 /* PBXTextBookmark */; 82 | B841BD8013ACE3D100F3B806 /* PBXTextBookmark */ = B841BD8013ACE3D100F3B806 /* PBXTextBookmark */; 83 | B84727DC13ABABD90044F64A /* PBXTextBookmark */ = B84727DC13ABABD90044F64A /* PBXTextBookmark */; 84 | B84727DD13ABABD90044F64A /* PBXTextBookmark */ = B84727DD13ABABD90044F64A /* PBXTextBookmark */; 85 | B858A18313B0D56200917536 /* PBXTextBookmark */ = B858A18313B0D56200917536 /* PBXTextBookmark */; 86 | B858A19313B0DB5C00917536 /* PBXTextBookmark */ = B858A19313B0DB5C00917536 /* PBXTextBookmark */; 87 | B858A1D613B0EB8C00917536 /* PBXTextBookmark */ = B858A1D613B0EB8C00917536 /* PBXTextBookmark */; 88 | B858A1D713B0EB8C00917536 /* PBXTextBookmark */ = B858A1D713B0EB8C00917536 /* PBXTextBookmark */; 89 | B858A1EB13B0EDE800917536 /* PBXTextBookmark */ = B858A1EB13B0EDE800917536 /* PBXTextBookmark */; 90 | B858A1EC13B0EDE800917536 /* PBXTextBookmark */ = B858A1EC13B0EDE800917536 /* PBXTextBookmark */; 91 | B858A22F13B0F37300917536 /* PBXTextBookmark */ = B858A22F13B0F37300917536 /* PBXTextBookmark */; 92 | B858A23B13B0F49700917536 /* PBXTextBookmark */ = B858A23B13B0F49700917536 /* PBXTextBookmark */; 93 | B858A24D13B0F7AC00917536 /* PBXTextBookmark */ = B858A24D13B0F7AC00917536 /* PBXTextBookmark */; 94 | B858A24E13B0F7AC00917536 /* PBXTextBookmark */ = B858A24E13B0F7AC00917536 /* PBXTextBookmark */; 95 | B858A24F13B0F7AC00917536 /* PBXTextBookmark */ = B858A24F13B0F7AC00917536 /* PBXTextBookmark */; 96 | B858A25013B0F7AC00917536 /* PBXTextBookmark */ = B858A25013B0F7AC00917536 /* PBXTextBookmark */; 97 | B858A25D13B0F8A700917536 /* PBXTextBookmark */ = B858A25D13B0F8A700917536 /* PBXTextBookmark */; 98 | B89CCC6C13AF8ED80009B69D /* PBXTextBookmark */ = B89CCC6C13AF8ED80009B69D /* PBXTextBookmark */; 99 | B89CCC6D13AF8ED80009B69D /* PBXTextBookmark */ = B89CCC6D13AF8ED80009B69D /* PBXTextBookmark */; 100 | B89CCC9713AF92AE0009B69D /* PBXTextBookmark */ = B89CCC9713AF92AE0009B69D /* PBXTextBookmark */; 101 | B89CCCB313AF932D0009B69D /* PBXTextBookmark */ = B89CCCB313AF932D0009B69D /* PBXTextBookmark */; 102 | B89CCCD013AF959F0009B69D /* PBXTextBookmark */ = B89CCCD013AF959F0009B69D /* PBXTextBookmark */; 103 | B89CCCD913AF95C50009B69D /* PBXTextBookmark */ = B89CCCD913AF95C50009B69D /* PBXTextBookmark */; 104 | B89CCD1413AF98FD0009B69D /* PBXTextBookmark */ = B89CCD1413AF98FD0009B69D /* PBXTextBookmark */; 105 | B89CCD2D13AF9AE90009B69D /* PBXTextBookmark */ = B89CCD2D13AF9AE90009B69D /* PBXTextBookmark */; 106 | }; 107 | sourceControlManager = B807A64A13AA25D900BE33A4 /* Source Control */; 108 | userBuildSettings = { 109 | }; 110 | }; 111 | 400AA20F13A9BB4D00DFD74F /* MainViewController.h */ = { 112 | uiCtxt = { 113 | sepNavIntBoundsRect = "{{0, 0}, {830, 594}}"; 114 | sepNavSelRange = "{293, 0}"; 115 | sepNavVisRange = "{0, 355}"; 116 | }; 117 | }; 118 | 400AA21013A9BB4D00DFD74F /* MainViewController.m */ = { 119 | uiCtxt = { 120 | sepNavIntBoundsRect = "{{0, 0}, {999, 884}}"; 121 | sepNavSelRange = "{1178, 0}"; 122 | sepNavVisRange = "{134, 1422}"; 123 | }; 124 | }; 125 | 400AA21213A9BB4D00DFD74F /* MKDicAppDelegate.m */ = { 126 | uiCtxt = { 127 | sepNavIntBoundsRect = "{{0, 0}, {830, 594}}"; 128 | sepNavSelRange = "{0, 0}"; 129 | sepNavVisRange = "{0, 782}"; 130 | }; 131 | }; 132 | 400AA21313A9BB4D00DFD74F /* SentenceViewController.h */ = { 133 | uiCtxt = { 134 | sepNavIntBoundsRect = "{{0, 0}, {830, 594}}"; 135 | sepNavSelRange = "{389, 0}"; 136 | sepNavVisRange = "{0, 800}"; 137 | }; 138 | }; 139 | 400AA21413A9BB4D00DFD74F /* SentenceViewController.m */ = { 140 | uiCtxt = { 141 | sepNavIntBoundsRect = "{{0, 0}, {1160, 1742}}"; 142 | sepNavSelRange = "{2022, 0}"; 143 | sepNavVisRange = "{2278, 1276}"; 144 | }; 145 | }; 146 | 400AA21513A9BB4D00DFD74F /* WordsViewController.h */ = { 147 | uiCtxt = { 148 | sepNavIntBoundsRect = "{{0, 0}, {1001, 573}}"; 149 | sepNavSelRange = "{510, 41}"; 150 | sepNavVisRange = "{0, 600}"; 151 | }; 152 | }; 153 | 400AA21613A9BB4D00DFD74F /* WordsViewController.m */ = { 154 | uiCtxt = { 155 | sepNavIntBoundsRect = "{{0, 0}, {1174, 1989}}"; 156 | sepNavSelRange = "{1012, 117}"; 157 | sepNavVisRange = "{350, 1276}"; 158 | }; 159 | }; 160 | 400AA23513A9BD2800DFD74F /* DownLoadData.h */ = { 161 | uiCtxt = { 162 | sepNavIntBoundsRect = "{{0, 0}, {830, 594}}"; 163 | sepNavSelRange = "{0, 0}"; 164 | sepNavVisRange = "{0, 708}"; 165 | }; 166 | }; 167 | 400AA23613A9BD2800DFD74F /* DownLoadData.m */ = { 168 | uiCtxt = { 169 | sepNavIntBoundsRect = "{{0, 0}, {830, 806}}"; 170 | sepNavSelRange = "{191, 0}"; 171 | sepNavVisRange = "{0, 1023}"; 172 | }; 173 | }; 174 | 400AA2F813A9CE3700DFD74F /* GeneralManager.m */ = { 175 | uiCtxt = { 176 | sepNavIntBoundsRect = "{{0, 0}, {1013, 988}}"; 177 | sepNavSelRange = "{1317, 135}"; 178 | sepNavVisRange = "{485, 1001}"; 179 | }; 180 | }; 181 | 40B5638813AAE5DE00B5A32B /* StudyViewController.h */ = { 182 | uiCtxt = { 183 | sepNavIntBoundsRect = "{{0, 0}, {1001, 573}}"; 184 | sepNavSelRange = "{683, 0}"; 185 | sepNavVisRange = "{0, 690}"; 186 | }; 187 | }; 188 | 40B5638913AAE5DE00B5A32B /* StudyViewController.m */ = { 189 | uiCtxt = { 190 | sepNavIntBoundsRect = "{{0, 0}, {936, 1521}}"; 191 | sepNavSelRange = "{3721, 0}"; 192 | sepNavVisRange = "{2727, 596}"; 193 | }; 194 | }; 195 | 8D1107260486CEB800E47090 /* MKDic */ = { 196 | activeExec = 0; 197 | executables = ( 198 | B807A63913AA25D400BE33A4 /* MKDic */, 199 | ); 200 | }; 201 | B807A63913AA25D400BE33A4 /* MKDic */ = { 202 | isa = PBXExecutable; 203 | activeArgIndices = ( 204 | ); 205 | argumentStrings = ( 206 | ); 207 | autoAttachOnCrash = 1; 208 | breakpointsEnabled = 1; 209 | configStateDict = { 210 | }; 211 | customDataFormattersEnabled = 1; 212 | dataTipCustomDataFormattersEnabled = 1; 213 | dataTipShowTypeColumn = 1; 214 | dataTipSortType = 0; 215 | debuggerPlugin = GDBDebugging; 216 | disassemblyDisplayState = 0; 217 | dylibVariantSuffix = ""; 218 | enableDebugStr = 1; 219 | environmentEntries = ( 220 | ); 221 | executableSystemSymbolLevel = 0; 222 | executableUserSymbolLevel = 0; 223 | libgmallocEnabled = 0; 224 | name = MKDic; 225 | savedGlobals = { 226 | }; 227 | showTypeColumn = 0; 228 | sourceDirectories = ( 229 | ); 230 | variableFormatDictionary = { 231 | }; 232 | }; 233 | B807A64A13AA25D900BE33A4 /* Source Control */ = { 234 | isa = PBXSourceControlManager; 235 | fallbackIsa = XCSourceControlManager; 236 | isSCMEnabled = 0; 237 | scmConfiguration = { 238 | repositoryNamesForRoots = { 239 | "" = ""; 240 | }; 241 | }; 242 | }; 243 | B807A64B13AA25D900BE33A4 /* Code sense */ = { 244 | isa = PBXCodeSenseManager; 245 | indexTemplatePath = ""; 246 | }; 247 | B807A69A13AA3C8100BE33A4 /* PBXTextBookmark */ = { 248 | isa = PBXTextBookmark; 249 | fRef = B807A69B13AA3C8100BE33A4 /* NSSearchField.h */; 250 | name = "NSSearchField.h: 12"; 251 | rLen = 41; 252 | rLoc = 203; 253 | rType = 0; 254 | vrLen = 601; 255 | vrLoc = 0; 256 | }; 257 | B807A69B13AA3C8100BE33A4 /* NSSearchField.h */ = { 258 | isa = PBXFileReference; 259 | lastKnownFileType = sourcecode.c.h; 260 | name = NSSearchField.h; 261 | path = /Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks/AppKit.framework/Versions/C/Headers/NSSearchField.h; 262 | sourceTree = ""; 263 | }; 264 | B807A69D13AA3C8100BE33A4 /* PBXTextBookmark */ = { 265 | isa = PBXTextBookmark; 266 | fRef = B807A69E13AA3C8100BE33A4 /* NSTextField.h */; 267 | name = "NSTextField.h: 62"; 268 | rLen = 66; 269 | rLoc = 1719; 270 | rType = 0; 271 | vrLen = 1436; 272 | vrLoc = 349; 273 | }; 274 | B807A69E13AA3C8100BE33A4 /* NSTextField.h */ = { 275 | isa = PBXFileReference; 276 | lastKnownFileType = sourcecode.c.h; 277 | name = NSTextField.h; 278 | path = /Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks/AppKit.framework/Versions/C/Headers/NSTextField.h; 279 | sourceTree = ""; 280 | }; 281 | B807A6C513AA3E4500BE33A4 /* PBXTextBookmark */ = { 282 | isa = PBXTextBookmark; 283 | fRef = B807A6C613AA3E4500BE33A4 /* NSResponder.h */; 284 | name = "NSResponder.h: 74"; 285 | rLen = 30; 286 | rLoc = 3638; 287 | rType = 0; 288 | vrLen = 2629; 289 | vrLoc = 2250; 290 | }; 291 | B807A6C613AA3E4500BE33A4 /* NSResponder.h */ = { 292 | isa = PBXFileReference; 293 | lastKnownFileType = sourcecode.c.h; 294 | name = NSResponder.h; 295 | path = /Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks/AppKit.framework/Versions/C/Headers/NSResponder.h; 296 | sourceTree = ""; 297 | }; 298 | B807A70413AA4C3D00BE33A4 /* CustomViewControllerProtocol.h */ = { 299 | uiCtxt = { 300 | sepNavIntBoundsRect = "{{0, 0}, {830, 594}}"; 301 | sepNavSelRange = "{225, 17}"; 302 | sepNavVisRange = "{0, 250}"; 303 | }; 304 | }; 305 | B807A70513AA4C9F00BE33A4 /* PBXTextBookmark */ = { 306 | isa = PBXTextBookmark; 307 | fRef = B807A70613AA4C9F00BE33A4 /* NSSegmentedControl.h */; 308 | name = "NSSegmentedControl.h: 29"; 309 | rLen = 44; 310 | rLoc = 679; 311 | rType = 0; 312 | vrLen = 1108; 313 | vrLoc = 0; 314 | }; 315 | B807A70613AA4C9F00BE33A4 /* NSSegmentedControl.h */ = { 316 | isa = PBXFileReference; 317 | lastKnownFileType = sourcecode.c.h; 318 | name = NSSegmentedControl.h; 319 | path = /Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks/AppKit.framework/Versions/C/Headers/NSSegmentedControl.h; 320 | sourceTree = ""; 321 | }; 322 | B807A72913AA4F7100BE33A4 /* PBXTextBookmark */ = { 323 | isa = PBXTextBookmark; 324 | fRef = B807A70413AA4C3D00BE33A4 /* CustomViewControllerProtocol.h */; 325 | name = "CustomViewControllerProtocol.h: 14"; 326 | rLen = 17; 327 | rLoc = 225; 328 | rType = 0; 329 | vrLen = 250; 330 | vrLoc = 0; 331 | }; 332 | B807A73C13AA526200BE33A4 /* Credits.rtf */ = { 333 | uiCtxt = { 334 | sepNavIntBoundsRect = "{{0, 0}, {850, 609}}"; 335 | sepNavSelRange = "{94, 0}"; 336 | sepNavVisRect = "{{0, 0}, {850, 609}}"; 337 | }; 338 | }; 339 | B807A76413AA59EC00BE33A4 /* PBXBookmark */ = { 340 | isa = PBXBookmark; 341 | fRef = B807A75A13AA594E00BE33A4 /* interact.icns */; 342 | }; 343 | B807A76513AA59EC00BE33A4 /* PBXTextBookmark */ = { 344 | isa = PBXTextBookmark; 345 | fRef = 089C165DFE840E0CC02AAC07 /* English */; 346 | name = "InfoPlist.strings: 1"; 347 | rLen = 0; 348 | rLoc = 0; 349 | rType = 0; 350 | vrLen = 45; 351 | vrLoc = 0; 352 | }; 353 | B807A76F13AA5A4D00BE33A4 /* PlistBookmark */ = { 354 | isa = PlistBookmark; 355 | fRef = 8D1107310486CEB800E47090 /* MKDic-Info.plist */; 356 | fallbackIsa = PBXBookmark; 357 | isK = 0; 358 | kPath = ( 359 | ); 360 | name = "/Users/tanhao/Desktop/MKDic/MKDic-Info.plist"; 361 | rLen = 0; 362 | rLoc = 9223372036854775808; 363 | }; 364 | B841BD2D13ACB3CD00F3B806 /* PBXTextBookmark */ = { 365 | isa = PBXTextBookmark; 366 | fRef = 400AA21413A9BB4D00DFD74F /* SentenceViewController.m */; 367 | name = "SentenceViewController.m: 79"; 368 | rLen = 0; 369 | rLoc = 2022; 370 | rType = 0; 371 | vrLen = 1276; 372 | vrLoc = 2278; 373 | }; 374 | B841BD7F13ACE3D100F3B806 /* PBXTextBookmark */ = { 375 | isa = PBXTextBookmark; 376 | fRef = 400AA21213A9BB4D00DFD74F /* MKDicAppDelegate.m */; 377 | name = "MKDicAppDelegate.m: 1"; 378 | rLen = 0; 379 | rLoc = 0; 380 | rType = 0; 381 | vrLen = 782; 382 | vrLoc = 0; 383 | }; 384 | B841BD8013ACE3D100F3B806 /* PBXTextBookmark */ = { 385 | isa = PBXTextBookmark; 386 | fRef = 400AA20F13A9BB4D00DFD74F /* MainViewController.h */; 387 | name = "MainViewController.h: 15"; 388 | rLen = 0; 389 | rLoc = 293; 390 | rType = 0; 391 | vrLen = 355; 392 | vrLoc = 0; 393 | }; 394 | B84727DC13ABABD90044F64A /* PBXTextBookmark */ = { 395 | isa = PBXTextBookmark; 396 | fRef = B807A73C13AA526200BE33A4 /* Credits.rtf */; 397 | name = "Credits.rtf: 2"; 398 | rLen = 0; 399 | rLoc = 94; 400 | rType = 0; 401 | vrLen = 94; 402 | vrLoc = 0; 403 | }; 404 | B84727DD13ABABD90044F64A /* PBXTextBookmark */ = { 405 | isa = PBXTextBookmark; 406 | fRef = 400AA21313A9BB4D00DFD74F /* SentenceViewController.h */; 407 | name = "SentenceViewController.h: 15"; 408 | rLen = 0; 409 | rLoc = 389; 410 | rType = 0; 411 | vrLen = 800; 412 | vrLoc = 0; 413 | }; 414 | B858A18313B0D56200917536 /* PBXTextBookmark */ = { 415 | isa = PBXTextBookmark; 416 | fRef = B858A18413B0D56200917536 /* NSPathUtilities.h */; 417 | name = "NSPathUtilities.h: 17"; 418 | rLen = 30; 419 | rLoc = 400; 420 | rType = 0; 421 | vrLen = 1335; 422 | vrLoc = 0; 423 | }; 424 | B858A18413B0D56200917536 /* NSPathUtilities.h */ = { 425 | isa = PBXFileReference; 426 | name = NSPathUtilities.h; 427 | path = /Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks/Foundation.framework/Versions/C/Headers/NSPathUtilities.h; 428 | sourceTree = ""; 429 | }; 430 | B858A19313B0DB5C00917536 /* PBXTextBookmark */ = { 431 | isa = PBXTextBookmark; 432 | fRef = B858A19413B0DB5C00917536 /* NSFileManager.h */; 433 | name = "NSFileManager.h: 106"; 434 | rLen = 164; 435 | rLoc = 7148; 436 | rType = 0; 437 | vrLen = 4259; 438 | vrLoc = 5431; 439 | }; 440 | B858A19413B0DB5C00917536 /* NSFileManager.h */ = { 441 | isa = PBXFileReference; 442 | name = NSFileManager.h; 443 | path = /Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks/Foundation.framework/Versions/C/Headers/NSFileManager.h; 444 | sourceTree = ""; 445 | }; 446 | B858A1CA13B0EABA00917536 /* NSTableView.h */ = { 447 | isa = PBXFileReference; 448 | lastKnownFileType = sourcecode.c.h; 449 | name = NSTableView.h; 450 | path = /Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks/AppKit.framework/Versions/C/Headers/NSTableView.h; 451 | sourceTree = ""; 452 | uiCtxt = { 453 | sepNavIntBoundsRect = "{{0, 0}, {5297, 8489}}"; 454 | sepNavSelRange = "{34828, 128}"; 455 | sepNavVisRange = "{33437, 5634}"; 456 | }; 457 | }; 458 | B858A1D613B0EB8C00917536 /* PBXTextBookmark */ = { 459 | isa = PBXTextBookmark; 460 | fRef = B89CCC7013AF8ED80009B69D /* sqlite3.h */; 461 | name = "sqlite3.h: 293"; 462 | rLen = 18; 463 | rLoc = 11292; 464 | rType = 0; 465 | vrLen = 1912; 466 | vrLoc = 10241; 467 | }; 468 | B858A1D713B0EB8C00917536 /* PBXTextBookmark */ = { 469 | isa = PBXTextBookmark; 470 | fRef = B89CCC9A13AF92AE0009B69D /* NSString.h */; 471 | name = "NSString.h: 259"; 472 | rLen = 98; 473 | rLoc = 15061; 474 | rType = 0; 475 | vrLen = 3084; 476 | vrLoc = 13830; 477 | }; 478 | B858A1EB13B0EDE800917536 /* PBXTextBookmark */ = { 479 | isa = PBXTextBookmark; 480 | fRef = B89CCC3513AF80920009B69D /* WordNoteDao.h */; 481 | name = "WordNoteDao.h: 31"; 482 | rLen = 0; 483 | rLoc = 875; 484 | rType = 0; 485 | vrLen = 881; 486 | vrLoc = 0; 487 | }; 488 | B858A1EC13B0EDE800917536 /* PBXTextBookmark */ = { 489 | isa = PBXTextBookmark; 490 | fRef = B89CCC3613AF80920009B69D /* WordNoteDao.m */; 491 | name = "WordNoteDao.m: 142"; 492 | rLen = 0; 493 | rLoc = 3661; 494 | rType = 0; 495 | vrLen = 771; 496 | vrLoc = 0; 497 | }; 498 | B858A22F13B0F37300917536 /* PBXTextBookmark */ = { 499 | isa = PBXTextBookmark; 500 | fRef = B858A23013B0F37300917536 /* NSIndexSet.h */; 501 | name = "NSIndexSet.h: 31"; 502 | rLen = 75; 503 | rLoc = 1159; 504 | rType = 0; 505 | vrLen = 1245; 506 | vrLoc = 567; 507 | }; 508 | B858A23013B0F37300917536 /* NSIndexSet.h */ = { 509 | isa = PBXFileReference; 510 | name = NSIndexSet.h; 511 | path = /Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks/Foundation.framework/Versions/C/Headers/NSIndexSet.h; 512 | sourceTree = ""; 513 | }; 514 | B858A23B13B0F49700917536 /* PBXTextBookmark */ = { 515 | isa = PBXTextBookmark; 516 | fRef = B858A1CA13B0EABA00917536 /* NSTableView.h */; 517 | name = "NSTableView.h: 539"; 518 | rLen = 128; 519 | rLoc = 34828; 520 | rType = 0; 521 | vrLen = 5634; 522 | vrLoc = 33437; 523 | }; 524 | B858A24D13B0F7AC00917536 /* PBXTextBookmark */ = { 525 | isa = PBXTextBookmark; 526 | fRef = 400AA21513A9BB4D00DFD74F /* WordsViewController.h */; 527 | name = "WordsViewController.h: 22"; 528 | rLen = 41; 529 | rLoc = 510; 530 | rType = 0; 531 | vrLen = 600; 532 | vrLoc = 0; 533 | }; 534 | B858A24E13B0F7AC00917536 /* PBXTextBookmark */ = { 535 | isa = PBXTextBookmark; 536 | fRef = 40B5638813AAE5DE00B5A32B /* StudyViewController.h */; 537 | name = "StudyViewController.h: 24"; 538 | rLen = 0; 539 | rLoc = 683; 540 | rType = 0; 541 | vrLen = 690; 542 | vrLoc = 0; 543 | }; 544 | B858A24F13B0F7AC00917536 /* PBXTextBookmark */ = { 545 | isa = PBXTextBookmark; 546 | fRef = 400AA21613A9BB4D00DFD74F /* WordsViewController.m */; 547 | name = "WordsViewController.m: 43"; 548 | rLen = 117; 549 | rLoc = 1012; 550 | rType = 0; 551 | vrLen = 1276; 552 | vrLoc = 350; 553 | }; 554 | B858A25013B0F7AC00917536 /* PBXTextBookmark */ = { 555 | isa = PBXTextBookmark; 556 | fRef = 40B5638913AAE5DE00B5A32B /* StudyViewController.m */; 557 | name = "StudyViewController.m: 68"; 558 | rLen = 0; 559 | rLoc = 1888; 560 | rType = 0; 561 | vrLen = 1488; 562 | vrLoc = 1159; 563 | }; 564 | B858A25D13B0F8A700917536 /* PBXTextBookmark */ = { 565 | isa = PBXTextBookmark; 566 | fRef = 40B5638913AAE5DE00B5A32B /* StudyViewController.m */; 567 | name = "StudyViewController.m: 10"; 568 | rLen = 0; 569 | rLoc = 194; 570 | rType = 0; 571 | vrLen = 1183; 572 | vrLoc = 0; 573 | }; 574 | B89CCC3213AF807F0009B69D /* WordNote.h */ = { 575 | uiCtxt = { 576 | sepNavIntBoundsRect = "{{0, 0}, {830, 571}}"; 577 | sepNavSelRange = "{255, 0}"; 578 | sepNavVisRange = "{0, 364}"; 579 | }; 580 | }; 581 | B89CCC3313AF807F0009B69D /* WordNote.m */ = { 582 | uiCtxt = { 583 | sepNavIntBoundsRect = "{{0, 0}, {830, 594}}"; 584 | sepNavSelRange = "{325, 0}"; 585 | sepNavVisRange = "{0, 333}"; 586 | }; 587 | }; 588 | B89CCC3513AF80920009B69D /* WordNoteDao.h */ = { 589 | uiCtxt = { 590 | sepNavIntBoundsRect = "{{0, 0}, {838, 594}}"; 591 | sepNavSelRange = "{875, 0}"; 592 | sepNavVisRange = "{0, 881}"; 593 | }; 594 | }; 595 | B89CCC3613AF80920009B69D /* WordNoteDao.m */ = { 596 | uiCtxt = { 597 | sepNavIntBoundsRect = "{{0, 0}, {830, 2106}}"; 598 | sepNavSelRange = "{3661, 0}"; 599 | sepNavVisRange = "{0, 771}"; 600 | }; 601 | }; 602 | B89CCC6C13AF8ED80009B69D /* PBXTextBookmark */ = { 603 | isa = PBXTextBookmark; 604 | fRef = 400AA23513A9BD2800DFD74F /* DownLoadData.h */; 605 | name = "DownLoadData.h: 1"; 606 | rLen = 0; 607 | rLoc = 0; 608 | rType = 0; 609 | vrLen = 708; 610 | vrLoc = 0; 611 | }; 612 | B89CCC6D13AF8ED80009B69D /* PBXTextBookmark */ = { 613 | isa = PBXTextBookmark; 614 | fRef = B89CCC6E13AF8ED80009B69D /* NSException.h */; 615 | name = "NSException.h: 179"; 616 | rLen = 38; 617 | rLoc = 6543; 618 | rType = 0; 619 | vrLen = 1558; 620 | vrLoc = 5751; 621 | }; 622 | B89CCC6E13AF8ED80009B69D /* NSException.h */ = { 623 | isa = PBXFileReference; 624 | lastKnownFileType = sourcecode.c.h; 625 | name = NSException.h; 626 | path = /Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks/Foundation.framework/Versions/C/Headers/NSException.h; 627 | sourceTree = ""; 628 | }; 629 | B89CCC7013AF8ED80009B69D /* sqlite3.h */ = { 630 | isa = PBXFileReference; 631 | lastKnownFileType = sourcecode.c.h; 632 | name = sqlite3.h; 633 | path = /usr/include/sqlite3.h; 634 | sourceTree = ""; 635 | uiCtxt = { 636 | sepNavIntBoundsRect = "{{0, 0}, {830, 71643}}"; 637 | sepNavSelRange = "{11292, 18}"; 638 | sepNavVisRange = "{10241, 1912}"; 639 | }; 640 | }; 641 | B89CCC9713AF92AE0009B69D /* PBXTextBookmark */ = { 642 | isa = PBXTextBookmark; 643 | fRef = B89CCC9813AF92AE0009B69D /* objc.h */; 644 | name = "objc.h: 61"; 645 | rLen = 29; 646 | rLoc = 1711; 647 | rType = 0; 648 | vrLen = 1023; 649 | vrLoc = 1159; 650 | }; 651 | B89CCC9813AF92AE0009B69D /* objc.h */ = { 652 | isa = PBXFileReference; 653 | lastKnownFileType = sourcecode.c.h; 654 | name = objc.h; 655 | path = /Developer/SDKs/MacOSX10.6.sdk/usr/include/objc/objc.h; 656 | sourceTree = ""; 657 | }; 658 | B89CCC9A13AF92AE0009B69D /* NSString.h */ = { 659 | isa = PBXFileReference; 660 | lastKnownFileType = sourcecode.c.h; 661 | name = NSString.h; 662 | path = /Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks/Foundation.framework/Versions/C/Headers/NSString.h; 663 | sourceTree = ""; 664 | uiCtxt = { 665 | sepNavIntBoundsRect = "{{0, 0}, {3659, 5317}}"; 666 | sepNavSelRange = "{15061, 98}"; 667 | sepNavVisRange = "{13830, 3084}"; 668 | }; 669 | }; 670 | B89CCCB313AF932D0009B69D /* PBXTextBookmark */ = { 671 | isa = PBXTextBookmark; 672 | fRef = 400AA21013A9BB4D00DFD74F /* MainViewController.m */; 673 | name = "MainViewController.m: 33"; 674 | rLen = 0; 675 | rLoc = 1178; 676 | rType = 0; 677 | vrLen = 1422; 678 | vrLoc = 134; 679 | }; 680 | B89CCCD013AF959F0009B69D /* PBXTextBookmark */ = { 681 | isa = PBXTextBookmark; 682 | fRef = B89CCC3213AF807F0009B69D /* WordNote.h */; 683 | name = "WordNote.h: 17"; 684 | rLen = 0; 685 | rLoc = 255; 686 | rType = 0; 687 | vrLen = 364; 688 | vrLoc = 0; 689 | }; 690 | B89CCCD913AF95C50009B69D /* PBXTextBookmark */ = { 691 | isa = PBXTextBookmark; 692 | fRef = B89CCC3313AF807F0009B69D /* WordNote.m */; 693 | name = "WordNote.m: 20"; 694 | rLen = 0; 695 | rLoc = 325; 696 | rType = 0; 697 | vrLen = 333; 698 | vrLoc = 0; 699 | }; 700 | B89CCD1413AF98FD0009B69D /* PBXTextBookmark */ = { 701 | isa = PBXTextBookmark; 702 | fRef = 400AA2F813A9CE3700DFD74F /* GeneralManager.m */; 703 | name = "GeneralManager.m: 70"; 704 | rLen = 135; 705 | rLoc = 1317; 706 | rType = 0; 707 | vrLen = 1001; 708 | vrLoc = 485; 709 | }; 710 | B89CCD2D13AF9AE90009B69D /* PBXTextBookmark */ = { 711 | isa = PBXTextBookmark; 712 | fRef = 400AA23613A9BD2800DFD74F /* DownLoadData.m */; 713 | name = "DownLoadData.m: 13"; 714 | rLen = 0; 715 | rLoc = 191; 716 | rType = 0; 717 | vrLen = 1023; 718 | vrLoc = 0; 719 | }; 720 | } 721 | -------------------------------------------------------------------------------- /xibs/WordsViewController.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 1060 5 | 11C74 6 | 1938 7 | 1138.23 8 | 567.00 9 | 10 | com.apple.InterfaceBuilder.CocoaPlugin 11 | 1938 12 | 13 | 14 | YES 15 | NSSearchFieldCell 16 | NSScrollView 17 | NSSearchField 18 | NSCustomView 19 | NSTextView 20 | NSButtonCell 21 | NSButton 22 | NSScroller 23 | NSCustomObject 24 | 25 | 26 | YES 27 | com.apple.InterfaceBuilder.CocoaPlugin 28 | 29 | 30 | PluginDependencyRecalculationVersion 31 | 32 | 33 | 34 | YES 35 | 36 | WordsViewController 37 | 38 | 39 | FirstResponder 40 | 41 | 42 | NSApplication 43 | 44 | 45 | 46 | 286 47 | 48 | YES 49 | 50 | 51 | 301 52 | {{236, 307}, {105, 32}} 53 | 54 | 55 | YES 56 | 57 | 67239424 58 | 134217728 59 | 加入生词本 60 | 61 | STHeitiSC-Light 62 | 13 63 | 16 64 | 65 | 66 | -2038284033 67 | 129 68 | 69 | 70 | 200 71 | 25 72 | 73 | 74 | 75 | 76 | 301 77 | {{20, 315}, {160, 22}} 78 | 79 | 80 | YES 81 | 82 | 343014976 83 | 268436544 84 | 85 | 86 | LucidaGrande 87 | 13 88 | 1044 89 | 90 | 91 | YES 92 | 1 93 | 94 | 6 95 | System 96 | textBackgroundColor 97 | 98 | 3 99 | MQA 100 | 101 | 102 | 103 | 6 104 | System 105 | controlTextColor 106 | 107 | 3 108 | MAA 109 | 110 | 111 | 112 | 130560 113 | 0 114 | search 115 | 116 | _searchFieldSearch: 117 | 118 | 138690815 119 | 0 120 | 121 | 400 122 | 75 123 | 124 | 125 | 130560 126 | 0 127 | clear 128 | 129 | YES 130 | 131 | YES 132 | 133 | YES 134 | AXDescription 135 | NSAccessibilityEncodedAttributesValueType 136 | 137 | 138 | YES 139 | cancel 140 | 141 | 142 | 143 | 144 | 145 | _searchFieldCancel: 146 | 147 | 138690815 148 | 0 149 | 150 | 400 151 | 75 152 | 153 | 255 154 | 155 | 156 | 157 | 158 | 301 159 | {{201, 313}, {29, 25}} 160 | 161 | 162 | YES 163 | 164 | 67239424 165 | 134217728 166 | 167 | 168 | 169 | -2030829313 170 | 34 171 | 172 | NSImage 173 | sentence_talk 174 | 175 | 176 | 177 | 200 178 | 25 179 | 180 | 181 | 182 | 183 | 319 184 | 185 | YES 186 | 187 | 188 | 2304 189 | 190 | YES 191 | 192 | 193 | 2322 194 | {438, 125} 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | YES 207 | 208 | 209 | 134 210 | 211 | 212 | 213 | 438 214 | 1 215 | 216 | 217 | 67120997 218 | 0 219 | 220 | 221 | 6 222 | System 223 | gridColor 224 | 225 | 3 226 | MC41AA 227 | 228 | 229 | 230 | YES 231 | 232 | YES 233 | NSBackgroundColor 234 | NSColor 235 | 236 | 237 | YES 238 | 239 | 6 240 | System 241 | selectedTextBackgroundColor 242 | 243 | 3 244 | MC42NjY2NjY2NjY3AA 245 | 246 | 247 | 248 | 6 249 | System 250 | selectedTextColor 251 | 252 | 253 | 254 | 255 | 256 | 257 | YES 258 | 259 | YES 260 | NSColor 261 | NSCursor 262 | NSUnderline 263 | 264 | 265 | YES 266 | 267 | 1 268 | MCAwIDEAA 269 | 270 | 271 | {8, -8} 272 | 13 273 | 274 | 275 | 276 | 277 | 278 | 279 | 1 280 | 281 | 6 282 | {463, 10000000} 283 | {223, 125} 284 | 285 | 286 | 287 | {{1, 1}, {438, 262}} 288 | 289 | 290 | 291 | 292 | 293 | 294 | {4, 5} 295 | 296 | 12582912 297 | 298 | YES 299 | 300 | YES 301 | 302 | 303 | 304 | TU0AKgAAAHCAFUqgBVKsAAAAwdVQUqwaEQeIRGJRGFlYqwWLQ+JxuOQpVRmEx2RROKwOQyOUQSPyaUym 305 | SxqWyKXyeYxyZzWbSuJTScRCbz2Nz+gRKhUOfTqeUai0OSxiWTiBQSHSGFquGwekxyAgAAAOAQAAAwAA 306 | AAEAEAAAAQEAAwAAAAEAEAAAAQIAAwAAAAIACAAIAQMAAwAAAAEABQAAAQYAAwAAAAEAAQAAAREABAAA 307 | AAEAAAAIARIAAwAAAAEAAQAAARUAAwAAAAEAAgAAARYAAwAAAAEAEAAAARcABAAAAAEAAABnARwAAwAA 308 | AAEAAQAAAT0AAwAAAAEAAgAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA 309 | 310 | 311 | 312 | 313 | 314 | 3 315 | MCAwAA 316 | 317 | 318 | 319 | 4 320 | 321 | 322 | 323 | -2147483392 324 | {{424, 1}, {15, 133}} 325 | 326 | 327 | 328 | _doScroller: 329 | 0.99248120300751874 330 | 331 | 332 | 333 | -2147483392 334 | {{-100, -100}, {87, 18}} 335 | 336 | 337 | 1 338 | 339 | _doScroller: 340 | 1 341 | 0.94565218687057495 342 | 343 | 344 | {{20, 35}, {440, 264}} 345 | 346 | 347 | 348 | 133649 349 | 350 | 351 | 352 | 353 | 354 | {480, 360} 355 | 356 | 357 | NSView 358 | 359 | 360 | 361 | 362 | YES 363 | 364 | 365 | view 366 | 367 | 368 | 369 | 2 370 | 371 | 372 | 373 | talkClick: 374 | 375 | 376 | 377 | 31 378 | 379 | 380 | 381 | toTextView 382 | 383 | 384 | 385 | 33 386 | 387 | 388 | 389 | searchField 390 | 391 | 392 | 393 | 36 394 | 395 | 396 | 397 | addNewWord: 398 | 399 | 400 | 401 | 41 402 | 403 | 404 | 405 | delegate 406 | 407 | 408 | 409 | 44 410 | 411 | 412 | 413 | 414 | YES 415 | 416 | 0 417 | 418 | YES 419 | 420 | 421 | 422 | 423 | 424 | -2 425 | 426 | 427 | File's Owner 428 | 429 | 430 | -1 431 | 432 | 433 | First Responder 434 | 435 | 436 | -3 437 | 438 | 439 | Application 440 | 441 | 442 | 1 443 | 444 | 445 | YES 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 22 455 | 456 | 457 | YES 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 23 466 | 467 | 468 | 469 | 470 | 24 471 | 472 | 473 | 474 | 475 | 25 476 | 477 | 478 | 479 | 480 | 29 481 | 482 | 483 | YES 484 | 485 | 486 | 487 | 488 | 489 | 30 490 | 491 | 492 | 493 | 494 | 34 495 | 496 | 497 | YES 498 | 499 | 500 | 501 | 502 | 503 | 35 504 | 505 | 506 | 507 | 508 | 39 509 | 510 | 511 | YES 512 | 513 | 514 | 515 | 516 | 517 | 40 518 | 519 | 520 | 521 | 522 | 523 | 524 | YES 525 | 526 | YES 527 | -1.IBPluginDependency 528 | -2.IBPluginDependency 529 | -3.IBPluginDependency 530 | 1.IBPluginDependency 531 | 22.IBPluginDependency 532 | 23.CustomClassName 533 | 23.IBPluginDependency 534 | 24.IBPluginDependency 535 | 25.IBPluginDependency 536 | 29.IBPluginDependency 537 | 30.IBPluginDependency 538 | 34.IBPluginDependency 539 | 35.IBPluginDependency 540 | 39.IBPluginDependency 541 | 40.IBPluginDependency 542 | 543 | 544 | YES 545 | com.apple.InterfaceBuilder.CocoaPlugin 546 | com.apple.InterfaceBuilder.CocoaPlugin 547 | com.apple.InterfaceBuilder.CocoaPlugin 548 | com.apple.InterfaceBuilder.CocoaPlugin 549 | com.apple.InterfaceBuilder.CocoaPlugin 550 | CutomerTextView 551 | com.apple.InterfaceBuilder.CocoaPlugin 552 | com.apple.InterfaceBuilder.CocoaPlugin 553 | com.apple.InterfaceBuilder.CocoaPlugin 554 | com.apple.InterfaceBuilder.CocoaPlugin 555 | com.apple.InterfaceBuilder.CocoaPlugin 556 | com.apple.InterfaceBuilder.CocoaPlugin 557 | com.apple.InterfaceBuilder.CocoaPlugin 558 | com.apple.InterfaceBuilder.CocoaPlugin 559 | com.apple.InterfaceBuilder.CocoaPlugin 560 | 561 | 562 | 563 | YES 564 | 565 | 566 | 567 | 568 | 569 | YES 570 | 571 | 572 | 573 | 574 | 44 575 | 576 | 577 | 578 | YES 579 | 580 | CutomerTextView 581 | NSTextView 582 | 583 | IBProjectSource 584 | ./Classes/CutomerTextView.h 585 | 586 | 587 | 588 | WordsViewController 589 | NSViewController 590 | 591 | YES 592 | 593 | YES 594 | addNewWord: 595 | talkClick: 596 | translateBegin: 597 | 598 | 599 | YES 600 | NSButton 601 | NSButton 602 | NSButton 603 | 604 | 605 | 606 | YES 607 | 608 | YES 609 | addNewWord: 610 | talkClick: 611 | translateBegin: 612 | 613 | 614 | YES 615 | 616 | addNewWord: 617 | NSButton 618 | 619 | 620 | talkClick: 621 | NSButton 622 | 623 | 624 | translateBegin: 625 | NSButton 626 | 627 | 628 | 629 | 630 | YES 631 | 632 | YES 633 | searchField 634 | toTextView 635 | 636 | 637 | YES 638 | NSSearchField 639 | NSTextView 640 | 641 | 642 | 643 | YES 644 | 645 | YES 646 | searchField 647 | toTextView 648 | 649 | 650 | YES 651 | 652 | searchField 653 | NSSearchField 654 | 655 | 656 | toTextView 657 | NSTextView 658 | 659 | 660 | 661 | 662 | IBProjectSource 663 | ./Classes/WordsViewController.h 664 | 665 | 666 | 667 | 668 | 0 669 | IBCocoaFramework 670 | 671 | com.apple.InterfaceBuilder.CocoaPlugin.macosx 672 | 673 | 674 | 675 | com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3 676 | 677 | 678 | YES 679 | 3 680 | 681 | sentence_talk 682 | {19, 19} 683 | 684 | 685 | 686 | --------------------------------------------------------------------------------