Waiting for the wind

programming memo in different platforms

iOS UIWebView and Javascript interactions

發文作者 cotton5415 於 二月 22, 2013

https://github.com/marcuswestin/WebViewJavascriptBridge

發表於 iPhone's Road | 已加上的標籤: , , | 張貼留言 »

Mac Port: mac os x 好用的工具之一

發文作者 cotton5415 於 一月 14, 2013

http://www.macports.org/install.php

發表於 MAC OS X's Road | 張貼留言 »

iOS PDF rendering performance improve items.

發文作者 cotton5415 於 十二月 7, 2012

http://stackoverflow.com/questions/3889634/fast-and-lean-pdf-viewer-for-iphone-ipad-ios-tips-and-hints

發表於 iPhone's Road | 已加上的標籤: , , , | 張貼留言 »

Auto increment build number by run script. (Xcode)

發文作者 cotton5415 於 七月 13, 2012

1. to add key in your Project-info.plist
CFBuildNumber, CFBuildDate
2. add scripts to your run script (in Xcode)
myPlist=$PROJECT_DIR/$PROJECT_NAME/$PROJECT_NAME-info.plist
CFBuildNumber=$(/usr/libexec/PlistBuddy -c “Print CFBuildNumber" $myPlist)
CFBuildNumber=$(($CFBuildNumber + 1))
/usr/libexec/PlistBuddy -c “Set :CFBuildNumber $CFBuildNumber" $myPlist
CFBuildDate=$(date)
/usr/libexec/PlistBuddy -c “Set :CFBuildDate $CFBuildDate" $myPlist
echo “build number: " $CFBuildNumber

3. get info from Project-info.plist and show on somewhere.
NSString * version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];
NSString * buildNo = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBuildNumber"];
NSString * buildDate = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBuildDate"];

發表於 MAC OS X's Road | 已加上的標籤: , , , , , | 張貼留言 »

Can’t debug iOS 4.2 with iPodTouch 3G in Xcode 4.3

發文作者 cotton5415 於 六月 19, 2012

This is regards to debug by Xcode 4.3 and attempting to run on an earlier device (e.g. iPhone 3G, 2G, iPod 1st gen, etc)
Solution: Remove ‘Required Device Capabilities’ in XXXX-info.plist if wanting to support devices that run armv6 (e.g. the iPhone 3G).

發表於 MAC OS X's Road | 已加上的標籤: , , , , | 張貼留言 »

instruments remote exception encountered

發文作者 cotton5415 於 六月 6, 2012

solution:
make sure your Xcode set the Profile scheme as Debug than Release.

發表於 MAC OS X's Road | 已加上的標籤: , , , , | 張貼留言 »

Grab Screen from Mac OS X Lion(10.7)

發文作者 cotton5415 於 十二月 29, 2011

Mac OS X Lion seams disable OpenGL screen. So, glReadPixel can’t get screen shot.
The solution to grab the screen:
CGImageRef image = CGDisplayCreateImage(kCGDirectMainDisplay);

發表於 MAC OS X's Road | 已加上的標籤: , , , , , , , , , , | 張貼留言 »

iOS 5 storyboard tutorial reference.

發文作者 cotton5415 於 十一月 11, 2011

http://kurrytran.blogspot.com/2011/07/simple-ios-5-tutorial-using-storyboard.html

發表於 MAC OS X's Road | 已加上的標籤: , , , | 張貼留言 »

cow, 改什麼storyboard…..xib 沒得用了。maintain 很麻煩。

發文作者 cotton5415 於 十月 17, 2011

http://chrislee.kr/wp/2011/07/24/mainwindow-xib-absence-in-xcode-4-2-beta-4-with-ios-5-sdk/

發表於 MAC OS X's Road | 已加上的標籤: , , , , , | 張貼留言 »

TCP 常見問題 1 : 如何知道對方不正常斷線?

發文作者 cotton5415 於 七月 13, 2011

問題: Peer A & Peer B 已經建立連線。但是Peer B突然電源線被拉掉,也沒電池撐著,或是突然B端的網路線被拉掉。這時候Peer A 的應用程式也沒有對B進行資料的收送。等到下次要搜送資料的時候,卻卡在send recv or read/write 當中。怎辦?
解法;利用 tcp keep alive.在socket 建立的時候 加上
int optval = 1 ;
setsockopt(sockfd, SOL_SOCKET, SO_KEEPALIVE, (const S8 *)&optval, sizeof(optval))
optval = 10 ; // seconds
setsockopt(sockfd, IPPROTO_TCP, TCP_KEEPALIVE, (const S8 *)&optval, sizeof(optval))
optval 設定成 timeout 的時間。這個timeout發生的時候, tcp 會送一個 SYN 給對方。

http://tldp.org/HOWTO/TCP-Keepalive-HOWTO/programming.html#setsockopt

發表於 MAC OS X's Road | 張貼留言 »

 
Follow

Get every new post delivered to your Inbox.