只需要將cookie存在cookieStorage裡即可 - (NSData *)send:(NSHTTPURLResponse**)urlResponse
{
NSError *errorState = nil;
NSData *result = [NSURLConnection sendSynchronousRequest:request returningResponse:urlResponse error:&errorState];
// process cookie
NSArray *allCookies = [NSHTTPCookie cookiesWithResponseHeaderFields:[*urlResponse allHeaderFields] forURL:[*urlResponse URL]];
if ([allCookies count]) {
[[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookies:allCookies forURL:[*urlResponse URL] mainDocumentURL:nil];
}
return result;
}

阿勇 發表在 痞客邦 留言(0) 人氣()

在設計iOS app時,常需要用到一些字型
這時候就可以參考一下font list
但是讓我疑惑的是,下列字體亦可依照 app 需求安裝是要如何安裝。
後來在apple上,發現這個

阿勇 發表在 痞客邦 留言(0) 人氣()

+ (UIColor*)colorWithColorCode:(NSString*)hex
{
NSString *cString = [[hex stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] uppercaseString];
// String should be 6 or 8 or 10 characters
if ([cString length] < 6) return [UIColor grayColor];
// strip 0X if it appears
if ([cString hasPrefix:@"0X"]) cString = [cString substringFromIndex:2];
if ([cString length] != 6 && [cString length] != 8) return [UIColor grayColor];
// Separate into r, g, b substrings
NSRange range;
range.location = 0;
range.length = 2;
NSString *rString = [cString substringWithRange:range];
range.location = 2;
NSString *gString = [cString substringWithRange:range];
range.location = 4;
NSString *bString = [cString substringWithRange:range];
NSString *aString = @"FF";
range.location = 6;
if ([cString length] == 8)
aString = [cString substringWithRange:range];
// Scan values
unsigned int r, g, b, a;
[[NSScanner scannerWithString:rString] scanHexInt:&r];
[[NSScanner scannerWithString:gString] scanHexInt:&g];
[[NSScanner scannerWithString:bString] scanHexInt:&b];
[[NSScanner scannerWithString:aString] scanHexInt:&a];
return [UIColor colorWithRed:((float) r / 255.0f)
green:((float) g / 255.0f)
blue:((float) b / 255.0f)
alpha:((float) a / 255.0f)];
}

阿勇 發表在 痞客邦 留言(0) 人氣()

今天突然發現我的元件上有一條白線,
不管是用path或讀圖畫出來的都後。
而且iOS6,還沒事。
google後,才發現是antialias搞。
CGContextSetShouldAntialias(context, NO); 參考

阿勇 發表在 痞客邦 留言(0) 人氣()

有thread和threading二種方式
參考
threadthreading

阿勇 發表在 痞客邦 留言(0) 人氣()

一直遇到php連不上MySQL的問題
mysqlnd cannot connect to MySQL 4.1+ using the old insecure authentication. Please use an administration tool to reset your password with the command SET PASSWORD = PASSWORD('your_existing_password'). This will store a new, and more secure, hash value in mysql.user. If this user is used in other scripts executed by PHP 5.2 or earlier you might need to remove the old-passwords flag from your my.cnf file
後來才發現原來是MySQL換密碼加密的方式,所以只要SET PASSWORD = PASSWORD('your_existing_password')
後來又發現要將SET SESSION old_passwords = 0;才行
詳細內容

阿勇 發表在 痞客邦 留言(0) 人氣()

UPDATE `tablename` SET `time`=DATE_SUB(`time`, INTERVAL 3 HOUR) WHERE 1

阿勇 發表在 痞客邦 留言(0) 人氣()

NSArray *words = @[@"list", @"of", @"words", @123, @3.14];
NSDictionary *d = @{ @"key": @"value" };
參考資料

阿勇 發表在 痞客邦 留言(0) 人氣()

今天發現,我的varchar竟然不能存成utf8,
google了一下,才發現是少了mysql_query(“SET NAMES ‘UTF8′");
參考

阿勇 發表在 痞客邦 留言(0) 人氣()

UIStoryboard *sb = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil]; UIViewController *vc = [sb instantiateViewControllerWithIdentifier:@"myViewController"];

阿勇 發表在 痞客邦 留言(0) 人氣()

最近發現,在連接gateway.sandbox.push.apple.com時,常常失敗。
經過追蹤後,才知道某些ip會連結失敗。
所以寫了一個 即時判斷的程式
$pushServer = 'gateway.sandbox.push.apple.com';
$host='';
$hosts = gethostbynamel($pushServer);
if (is_array($hosts)) {
foreach ($hosts as $host) {
$connection = fsockopen($host, 2195);
if (is_resource($connection)){
break;
}
}
if($host=='')
return;
} else {
return;
}

阿勇 發表在 痞客邦 留言(0) 人氣()


這是最好的方法,包跨會將auto increase清0
TRUNCATE TABLE tablename

這只是單純的清空
DELETE FROM tablename

阿勇 發表在 痞客邦 留言(0) 人氣()

Blog Stats
⚠️

成人內容提醒

本部落格內容僅限年滿十八歲者瀏覽。
若您未滿十八歲,請立即離開。

已滿十八歲者,亦請勿將內容提供給未成年人士。