試了半天也找了很多的資料,就是看不到有什麼解釋,只知道在設定hbm中設定property的type時,若使用的是sybase資料庫,type設定成text會有問題,會一直出現下列的Exception:
org.hibernate.MappingException: No Dialect mapping for JDBC type: -1
猜就是type不支援。查了資料,大多都說Text是varchar(4000),要用就type="string" length="4000",這樣設定就過了,不過4000也太大了吧
2013年8月13日 星期二
2013年8月11日 星期日
原來在HTTPS是可以做HTML content cache
一直以為HTTPS下是無法做HTML content cache,查了下才發現預設是可以的,大家可以看這篇:Will web browsers cache content over https
參考網址:
Will web browsers cache content over https
參考網址:
Will web browsers cache content over https
2013年8月8日 星期四
iOS開發筆記 - 使用Regular expression比對電話前置字串
做個紀錄
需求:
這樣就ok了~
參考網址:
NSRegularExpression Class Reference
User regular expression to find/replace substring in NSString
需求:
- 針對+86 123234534或+886 097xxxxx
大概的寫法是:
NSError *error = NULL;
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"^[\\+][0-9]+(\\s)|^[\\+]" options:NSRegularExpressionCaseInsensitive error:&error];
NSString *mobile = @"+86 123456789";
NSString *modifiedString = [regex stringByReplacingMatchesInString: mobile options:0 range:NSMakeRange(0, [mobileChanged length]) withTemplate:@""];
NSLog(@"%@", modifiedString);
這樣就ok了~
參考網址:
NSRegularExpression Class Reference
User regular expression to find/replace substring in NSString
iOS開發筆記 - NSString取代字串中某個文字
記錄一下,NSString取代字串中某個文字的方式
NSString *str = @"This is a string. That is a string";str = [str stringByReplacingOccurrencesOfString:@"string" withString:@"duck"];
這方式會搜尋整個字串,用後面的字取代所有符合前面字串的字
2013年8月4日 星期日
iOS開發筆記 - TTTAttributedLabel的使用
最近對UILable有些需求:
mattt / TTTAttributedLabel有蠻完整的範例,不過這邊還是紀錄一下。
Step 1:
COPY兩個檔案:TTTAttributedLabel.h及TTTAttributedLabel.m
Step 2:
加入CoreText.framework
Step 3(若專案本身是ARC不需要這步驟):
至Build Paases -> Compile Sources中找到TTTAttributedLabel.m加入-fobjc-arc
再來就可以使用了。以我自己的為例:
先將要使用這元件的ViewController或Class加上TTTAttributedLabelDelegate
電話號碼:
開網址:
還蠻簡單易用。
- 有link點擊
- 若是電話號碼可以打電話
- 若是連結可以開網址
- 若是地圖可以開Apple Map
mattt / TTTAttributedLabel有蠻完整的範例,不過這邊還是紀錄一下。
Step 1:
COPY兩個檔案:TTTAttributedLabel.h及TTTAttributedLabel.m
Step 2:
加入CoreText.framework
Step 3(若專案本身是ARC不需要這步驟):
至Build Paases -> Compile Sources中找到TTTAttributedLabel.m加入-fobjc-arc
再來就可以使用了。以我自己的為例:
先將要使用這元件的ViewController或Class加上TTTAttributedLabelDelegate
電話號碼:
TTTAttributedLabel *tel = [[TTTAttributedLabel alloc] initWithFrame:CGRectMake(10, 10, 190, 21)];tel.delegate = self;
if (tel.text != nil && ![tel.text isEqualToString:@""]) {
//電話號碼的範圍是整個字串
[tel addLinkToPhoneNumber:tel.text withRange: [tel.text rangeOfString:tel.text] ];
}
開網址:
TTTAttributedLabel *webSite = [[TTTAttributedLabel alloc] initWithFrame:CGRectMake(10, 10, 190, 21)];
webSite.delegate = self;
if (webSite.text != nil && ![webSite.text isEqualToString:@""]) {
//網址的範圍是整個字串
NSURL *urlString = [[NSURL alloc] initWithString:[@"http://" stringByAppendingString: webSite.text]];
[webSite addLinkToURL:urlString withRange:[webSite.text rangeOfString: webSite.text] ];
}
開Apple Map:
TTTAttributedLabel *addrLabel = [[TTTAttributedLabel alloc] initWithFrame:CGRectMake(10, 10, 190, 21)];
addrLabel.delegate = self;
if (addrLabel.text != nil && ![addrLabel.text isEqualToString:@""]) {
//地址的範圍是整個字串
NSDictionary *addr = @{@"addr": addrLabel.text};
[addrLabel addLinkToAddress:addr withRange: [addrLabel.text rangeOfString: addrLabel.text] ];
}還蠻簡單易用。
訂閱:
文章 (Atom)