Katex

2012年9月12日 星期三

Mac Day 17 - NSFileManager



NSFileManager 

初始化


有兩種方式:

(1) init 實體方法建立

        NSFileManager *fm = [NSFileManager new];

(2) 使用系統共享的單一物件 (singleton)

        NSFileManager *fm = [NSFileManager defaultManager];

從 Mac OS 10.5 之後建議使用 init 實體方式建立

取得目前所在目錄位置


        NSString *path = [fm currentDirectoryPath];
        NSLog(@"Current directory path is %@", path);

顯示目錄下檔案 (不包括子目錄)


        NSString *path1 = [fm currentDirectoryPath];
        NSDirectoryEnumerator *dirEnum = [fm enumeratorAtPath: path1];
        
        BOOL flag;
        while ((path = [dirEnum nextObject]) != nil) {
            NSLog(@"%@", path);
            
            [fm fileExistsAtPath:path isDirectory: &flag];
            
            if (flag == YES)
                [dirEnum skipDescendants];
        }





2012年9月11日 星期二

Mac Day 16 - Dictionary



Mac 本身有內建的字典軟體, 可以選擇不同的字典




另外可以安裝 "21世紀英漢漢英字典", 可以從以下鏈結下載, 可用在 Mac OS Lion
http://www.mediafire.com/download.php?zfrug1ufyee,作者是 Mechman,



網頁瀏覽查詢

可按 Control + Command + D 來呼叫字典查詢.




語音

Mac 本身有語音功能, 可在 System Preference -> Dictation&Speech 中設定.
可以更改Hot key 成相近的設定, 方便閱讀網頁時, 發音和查詢字典


Apple 供應鏈

2012 : 去三星化


A6,A7 處理器 : 台積電

小尺寸面板: Japan Display, LG, Sharp

鋰電池: ATL, Sanyo

LED 背光: 日亞化 (Nichia), 豐田合成 (TG)


====

iPad - 2010 台灣供應鏈

供應類別 公司 股號
組裝 鴻海 2317
觸控面板感測器 勝華 2384
印刷電路板 欣興 3037
健鼎 3044
華通 2313
機殼 鴻準 2354
可成 2474
被動元件 國巨 2327
美磊 3068
石英IC 晶技 3042
驅動IC 聯詠 3034
電池 新普 6121
連接器 正崴 2392
萬旭 6134
外接鍵盤與支架 達方 8163
濱川 1569

2012年9月10日 星期一

Mac Day 15 - Objective C - NSMutableArray

NSMutableArray : 動態陣列




1. [NSMutableArray array]
    [[[NSMutableArray alloc] init] autorelease]



2.  addObject

NSMutableArray *array = [NSMutableArray array];
 [array addObject:@"first"];
 [array addObject:@"second"];

3. 個數
[array count];



2012年9月8日 星期六

Mac Day 13 - Font Book

中文字型安裝

1. Font Book










2. 選擇字型:













3. 設定使用該字型



4. 設定後系統自動下載



5. 完成後即可選擇使用.

2012年9月7日 星期五

MAC Day 12 - Objective C - Class

和 C / C++ 不同地方

1. #import
   是當初 C: #include 的改良版, 保證標頭檔只會被匯入一次
   換言之, 標頭檔 就不用寫成像 :


#ifndef _XXX_H_
#define _XXX_H_
...
#endif

   而可以直接宣告


2.  @autoreleasepool

3.  物件

C++:


obj->method(argument);


Objective C:


[obj method: argument];



[ ClassOrInstance method ];

myDog = [Dog new];
[myDog run];


4. Interface

@interface NewClassName : ParentClassName
    propertyAndMethodDeclarations;
@end



@interface MyObject : NSObject 

+(return_type) class_method;            // 類方法
 
-(return_type) instance_method1;        // 實體方法
-(return_type) instance_method2: (int) p1;
-(return_type) instance_method3: (int) p1 andPar: (int) p2;

@end


+: 類似於 C++ : static function

5. Implementation

@implementation NewClassName
{
    memberDeclarations;
}
    methodDefinitions;
@end



@implementation MyObject
{
    int memberVar1; // 實體變數
    id  memberVar2;
}
+(return_type) class_method { .... //method implementation } -(return_type) instance_method1 { .... } -(return_type) instance_method2: (int) p1 { .... } -(return_type) instance_method3: (int) p1 andPar: (int) p2 { .... } @end


6. NSObject
http://developer.apple.com/library/ios/#documentation/Cocoa/Reference/Foundation/Classes/NSObject_Class/Reference/Reference.html



7. program



@interface Dog: NSObject
-(void) print;
-(void) setName: (NSString*) name;
@end
@implementation Dog 
{
    NSString *name;
}
-(void) print {
    NSLog(@"%@"name);
}
-(void) setName: (NSString*) n {
    name = n;
}
@end
int main(int argc, const char * argv[])
{      
    @autoreleasepool {
        Dog *myDog;
        NSString *name = @"WonWon";
        
        myDog = [Dog new];
        
        [myDog setName: name];
        
        NSLog(@"My dog's name is");
        [myDog print];
        
    }
    return 0;
}





熱門文章