網頁

2010年7月21日 星期三

Cocoa-Other

NSString

NSString 2 char
const char* cString = [nsStringObj cStringUsingEncoding:ASCIIEncoding];
[nsStringObj UTF8String];


char 2 NSString by encoding
[NSString stringWithCString:temp encoding:NSUTF8StringEncoding];


Join string array to single string
NSArray * stuff = /* ... */;
NSString * combinedStuff = [stuff componentsJoinedByString:@"separator"];
and inverse by [NSString componentsSeparatedByString:]


=========================================

exist file
BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:somePath];


=========================================

是否有相交
CGRectIntersection


=========================================

亂數
srand(time(NULL));random();
arc4random


=========================================

typeof
if(typeof([ErrorIDQuestion alloc])==typeof(question))
f( [[myObject className] isEqual: @"NSString"])

沒有留言:

張貼留言