Archive for the ‘Apple’ Category.
Objective-C , output format ref.
• %@ 物件
• %d, %i 整数
• %u 非負整數
• %f 浮點數
• %x, %X 十六進制整數
• %o 八進制整數
• %zu size_t
• %p 指標
• %e 浮點數 (科學計算)
• %g 浮點數
• %s C字串
• %.*s Pascal字串
• %c char字元
• %C unichar
• %lld 64位元長整數(long long)
• %llu 非負64位元長整數
• %Lf 64位元浮點數
Firewire 800 speed test!
[2010/9/3 下午6:05:46] _RTN Jason Chen: Firewire 800 外接盒效能還不錯,TimeMachine的差異備份很快。
[2010/9/3 下午6:22:44] _RTN Jason Chen:
1GB 檔案複製速度:
SATA -> SATA : 12sec
SATA -> FW800 : 21sec
SATA -> USB2.0 : 30sec
[2010/9/3 下午6:24:33] _RTN Jason Chen:
Xbench Disk Test:Sequential Uncached Read
500G SATA 7200轉:106MB/sec
USB 160G 5400轉:36MB/sec
FW800 250G 5400轉:80MB/sec
[MEMO/TIPS] iPhone class / method / instance naming convention
class : 大寫開頭
method / instance : 小寫
Property List / SQLite 寫法 sample
類似 printf 的寫法
NSString *debugMsg = [NSString stringWithFormat:@"Process %d", 1];
取亂數
定義:
#define RANDOM_SEED() srandom(time(NULL))
#define RANDOM_INT(__MIN__, __MAX__) ((__MIN__) + random() % ((__MAX__+1) - (__MIN__)))
// --- 這樣用
NSLog(@"%d" , RANDOM_INT(0,9) );
取 unixtime :
NSDate *past = [NSDate date];
NSTimeInterval oldTime = [past timeIntervalSinceDate:[NSDate dateWithNaturalLanguageString:@"01/01/1970"]];
NSString *unixTime = [[NSString alloc] initWithFormat:@"%0.0f", oldTime];
NSLog(@"%@" , unixTime);
印出 debug message / popup alert 的寫法:
// ---
-(void) printdebug:(id)msg {
NSLog(@"%@", msg);
}
// ---
-(void) displayAlertMessage:(id)msg {
// Display AlertView
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"___Alert___" message:msg
delegate:self cancelButtonTitle:@"Close" otherButtonTitles: nil];
[alert show];
[alert release];
}
Objective-C 奇怪的 null detect!
if ( (NSNull *)[item objectForKey:@"nick"]==[NSNull null] ) {
// FOR GUEST DATA
cell.textLabel.text = @"Guest";
} else {
// FOR MEMBER DATA
cell.textLabel.text = [item objectForKey:@"nick"];
}
ASYNC network 寫法:
http://mobile.tutsplus.com/tutorials/iphone/iphone-json-twitter-api/
—-
[書上沒教的] iPhone / xcode 出現這種 error : Check dependencies …error: There is no SDK with the name or path ‘iphoneosx.x’
想抓別人的 iphone project 來試玩看看, 在 build 時會有這種 message 的解決方法
Check dependencies
error: There is no SDK with the name or path ‘iphoneos2.2′
重選 “Base SDK for All Configurations” , 如圖:


