跳到主要內容

文章

目前顯示的是 2016的文章

[iOS] build universal library

1.「Product」->「Scheme」->「Edit Scheme」,切到「Run」分頁,將「Build Configuration」切換為「Release」。 2a. 分別build出simulator lib and iphone lib,再執行合併程式 lipo -create $(PATH_TO_libMZKit-iphonesimulator.a) $(PATH_TO_libMZKit-iphoneos.a) -output libMZKit.a 2a. Add Run Script # define output folder environment variable UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/${CONFIGURATION}-universal Step 1. Build Device and Simulator versions xcodebuild -target TargetName ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphoneos BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" xcodebuild -target TargetName ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphonesimulator BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" make sure the output directory exists mkdir -p "${UNIVERSAL_OUTPUTFOLDER}" Step 2. Create universal binary file using lipolipo -create -output "${UNIVERSAL_OUTPUTFOLDER}/lib${PROJECT_NAME}.a" "${BUILD_DIR}/${CONFIG

[Xcode] include library project

1 Add new Target setting to your Podfile 2 Run pod install, then new thing will appear in the left view of Xcode 3 Setting Link Binary With Libraries 4 Setting Copy Bundle Resources 5 Setting User Header Search Paths in Build Settings 6 target的build settings, 把「Generate Debug Symbol」設成「YES」。 把「Strip Debug Symbols During Copy」設成「NO」。

Google Sheets

1. 將某一欄位的值產生出類似key=value的效果 // AA -> “AA”=“AA”; ="""" & A2 & """=""" & A2 & """;" Google 試算表函式清單 https://support.google.com/docs/table/25273?hl=zh-Hant Google Apps Script https://developers.google.com/apps-script/ Extending Google Sheets https://developers.google.com/apps-script/guides/sheets http://jamestw.logdown.com/posts/517286-google-apps-script 原來Google雲端硬碟也能開放「匿名上傳」,做為學生作業、比賽稿件上傳就不用再傷腦筋了!(Google Apps Script應用服務指令碼) http://harmonica80.blogspot.tw/2015/08/googlegoogle-apps-script.html 這是利用Python 價格追蹤:使用 gspread 自動更新 Google Sheets http://city.shaform.com/blog/2016/03/19/gspread.html

[iOS] Enum

Objective-C //NS_ENUM,定義狀態等普通枚舉 typedef NS_ENUM(NSUInteger, TTGState) { TTGStateOK = 0, TTGStateError, TTGStateUnknow }; //NS_OPTIONS,定義選項 typedef NS_OPTIONS(NSUInteger, TTGDirection) { TTGDirectionNone = 0, TTGDirectionTop = 1 << 0, TTGDirectionLeft = 1 << 1, TTGDirectionRight = 1 << 2, TTGDirectionBottom = 1 << 3 }; 參考 http://blog.csdn.net/annkie/article/details/9877643 Swift //簡易定義:首字母大寫 enum Color { case blue case red case green case gray case white case black } //複雜定義 enum ColorWithDesc:String { case blue = "藍色" case red = "紅色" case green = "綠色" case gray = "灰色" case white = "白色" case black = "黑色" } 參考 http://www.99ios.com/index.php/archives/3153/

[iOS] 產生iOS Documents - 使用Doxygen

使用Doxygen: 安裝 from: http://www.stack.nl/~dimitri/doxygen/download.html If you have GIT installed, you should do the following to get the initial copy of the repository: git clone https://github.com/doxygen/doxygen.git cd doxygen After that you can use mkdir build cd build cmake -G "Unix Makefiles" .. make To force a fresh build after an earlier check-out simple remove the build directory and redo the steps above. After the binaries have been built, you can use make install to install them. 使用 1 產生設定檔 doxygen -g ProjectNameConfig 2 修改設定 PROJECT_NAME = OpenCV 2.4.9 # 改成自己要的專案名字 PROJECT_NUMBER = 1.0 # 專案的版本 OUTPUT_DIRECTORY = ../docs/OpenCV2.4.9 # 輸出的位置 INPUT = /usr/local/Cellar/opencv/2.4.9 # 讀取的位置 CREATE_SUBDIRS = YES OUTPUT_LANGUAGE = Chinese-Traditional FULL_PATH_NAMES = NO EXTRACT_STATIC = YES FILE_PATTERNS = *.h *.m *.swift #讀進的副檔名, 不需要逗號 RECURSIVE = YES REFERENCED_BY_RELATION = YES REFERENCES_RELATION = YES INLINE_SOURCE = YES EXTRACT_ALL = YES 3 支援繪圖 安裝Graph

[iOS] 取得sim卡資訊

CTTelephonyNetworkInfo *networkInfo = [CTTelephonyNetworkInfo new]; CTCarrier *carrier = [networkInfo subscriberCellularProvider]; //detect sim card status [networkInfo setSubscriberCellularProviderDidUpdateNotifier:^(CTCarrier* carrier) { NSString *countryCode = carrier.mobileCountryCode; NSString *networkCode = carrier.mobileNetworkCode; }];

JSON in javascript

印出所有的JSON內容: console.log(JSON.stringify(josnObj));     增加資料到 JSON Array: var jsonArray = []; jsonArray.push(“xxxxxxxx”); jsonArray.push({     “key”: value });   Jason array size: Object.keys(jsonArray).length

Thread Safe Method for Java

class MyCounter {     private static int counter = 0;     public static synchronized int getCount() {         return counter++;     } } from http://www.programcreek.com/2014/02/how-to-make-a-method-thread-safe-in-java/ 寫了一陣子iOS,感覺Java已經離我很遠了~ 只記得有這東西,但不記得怎麼用了…

[IOS] 中文字串比大小

//程式碼 func compartStringByUnicode(string1 string1: String, string2: String, asc: Bool, index: Int)->Bool{ MyVariables.logger.debug("===============> index=\(index), asc=\(asc)") let string1LengthEnough = string1.length > index let string2LengthEnough = string2.length > index if string1LengthEnough && string2LengthEnough { let targetChar1 = string1.characters.map { String($0) }[index] let targetChar2 = string2.characters.map { String($0) }[index] for u1 in targetChar1.utf16 { for u2 in targetChar2.utf16 { if u1 == u2 { return compartStringByUnicode(string1: string1, string2: string2, asc: asc, index: (index+1)) }else{ MyVariables.logger.debug("\(targetChar1) (\(u1), \(targetChar2) (\(u2)) ==> \(u1 < u2)") if asc {

CoronaSDK scene template

----------------------------------------------------------------------------------------- -- -- covermenu.lua -- TapTapUFO -- -- Created by Kirk Hsu on 2016/04/06. -- Copyright © 2016年 Kirk Hsu. All rights reserved. -- ----------------------------------------------------------------------------------------- -- 引入各種函試庫 local widget = require("widget") local composer = require("composer") local scene = composer.newScene() -- 以下為定義變數 -- 以上為定義變數 -- 以下為定義其他函式 -- 以上為定義其他函式 -- composer function scene:create(event) local screenGroup = self.view print("scene create") -- todo end function scene:show(event) if event.phase == "did" then print("scene did show") -- todo end end function scene:hide(event) if event.phase == "will" then print("scene will hide") -- todo end end function scene:destroy(event) if event.phase == "will" then print("scene will destroy") -- todo end end scene:addE

Corona SDK template

----------------------------------------------------------------------------------------- -- -- main.lua -- ProjectName -- -- Created by Kirk Hsu on 2016/04/06. -- Copyright © 2016年 Kirk Hsu. All rights reserved. -- ----------------------------------------------------------------------------------------- --display.setStatusBar( display.DefaultStatusBar ) --display.setStatusBar( display.DarkStatusBar ) display.setStatusBar( display.HiddenStatusBar ) --display.setStatusBar( display.TranslucentStatusBar ) -- 以下為定義變數 -- 以上為定義變數 local main = function() end -- 以下為定義其他函式 -- 以上為定義其他函式 main() -- 呼叫main()函式

iOS作品集(2016/03/31)

APP專案作品︰ 顯示加密內文 自己的作品︰ 台股評價分析   台股營收分析   台股獲利分析   選擇權策略   靠譜(for iPad)   LiveTV        

[MAC] 將wav+cue檔切成mp3

有時從網路取得的檔案會是一整個wav或flac再加一個cue檔來描述 但這種檔案在播放時得用特定的軟體來播,所以還是分開來比較方便~   軟體位置 http://external.informer.com/mediahuman.com/youtube-to-mp3-converter   wav and cue file               開啟app並將wav檔拉進去                                     點Yes,                                        設定輸出的格式,因為是自己要聽的,就選高一點                     全選匯出就完成啦                                       會多一個新的目錄Converted by MediaHuman,切好的檔案會在這                     至於中文亂碼的問題,我是再打開Tag Editor Free來編輯~    

Sublime Plugins

安裝 Package Control 1.按下command + ~ 2.貼上import command https://packagecontrol.io/installation#st2 JsFormat (排版) cmd + alt + f JSHint ctrl + j Pretty JSON ctrl + alt + j Alignment ctrl + alt + a Trimmer ctrl + alt + s Find Function Definition F8 keymapManager ctrl + alt + k   中文亂碼 Codecs33 https://github.com/seanliang/Codecs33/tree/osx   簡繁轉 ChineseOpenConvert https://packagecontrol.io/packages/ChineseOpenConvert

[iOS] TextView Attributes 設定 字型 樣式

TextView Attributes 設定 字型 樣式                    var noteContent = "" noteContent += "條碼使用時機\n" noteContent += "1、結帳時出示「手機條碼」累計消費\n" noteContent += "2、出示「消費折抵/贈獎兌換條碼」使用電子贈品禮券或兌換卡友禮\n\n" noteContent += "加入會員好處\n" noteContent += "1、享有停車優惠\n" noteContent += "2、省下周慶時排隊換禮券的時間\n" noteContent += "3、卡友周慶可獨享購物禮遇\n" let optimumTextViewFontSize: CGFloat = 14.0 let myAttribute = [ NSForegroundColorAttributeName: UIColor.whiteColor(), NSFontAttributeName: UIFont.systemFontOfSize(optimumTextViewFontSize) ] let myString = NSMutableAttributedString(string: noteContent, attributes: myAttribute ) let myAttribute2 = [ NSForegroundColorAttributeName: UIColor(hexString: "#E7B3B0")!, NSFontAttributeName: UIFont.boldSystemFontOfSize(optimumTextViewFontSize + 8), NSUnderlineStyleAttributeName: 1 ] let myString2 = NSMutableAttributedString(string: "現在立即加入,還可獲得100點\n", attributes:

[iOS] 動態 的 UITableViewCell Height

動態 的 UITableViewCell Height var heightsCache: Dictionary = [:] var cellDefaultHeight: CGFloat! override func viewDidLoad() { self.tableView.dataSource = self self.tableView.delegate = self let scale = UISizeUtils.getScaleFromPlus(self.view) // height = 621 self.cellDefaultHeight = 621.0 * scale tableView.rowHeight = UITableViewAutomaticDimension tableView.estimatedRowHeight = self.cellDefaultHeight ... } func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { ... self.heightsCache[indexPath] = newCellHeight ... } // MARK: - UITableViewDelegate func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat { let height = self.heightsCache[indexPath] if height != nil { return height! }else{ return self.cellDefaultHeight } }

[iOS] 取得目前正顯示的view

目的是為了寫一個簡易的show alert message的method //程式碼 extension UIApplication { class func topViewController(base base: UIViewController? = UIApplication.sharedApplication().keyWindow?.rootViewController) -> UIViewController? { if let nav = base as? UINavigationController { return topViewController(base: nav.visibleViewController) } if let tab = base as? UITabBarController { if let selected = tab.selectedViewController { return topViewController(base: selected) } } if let presented = base?.presentedViewController { return topViewController(base: presented) } return base } } //用法 let presentedView = UIApplication.topViewController() AlertMessageUtils.showSimpleAlert("系統通知", message: "電量\(values[0])%", view: presentedView!) 參考︰Find the current top view controller for your iOS application https://gist.github.com/snikch/3661188