2013年11月16日 星期六
[iOS] Web api with CoreData
像是 AFIncrementalStore
但是其實我沒有用過
現在也沒有空去改用
原因是.... 遇到太多的廠商開的api是在亂七八糟....
因此還是得自己針對案子去設計model
不過最近遇到下面的問題
-> 當 api 有 paging的功能,卻設計了一個 infinite scroll view
一般來說我常用的作法是
api -> 接到的data 直接存在 CoreData中
view -> 透過 NSFetchedResultsController 拿 CoreData的資料
但是如果加上了 page呢?
page意味著說每頁的資料在每次拿可能都不一樣
api 是"一頁一頁"的呈現資料
但是 UI 設計的是一個 infinite scroll view
並不會知道轉到了哪一頁(往往後端又想保留每頁可以動態調整資料數量的權力),即便是每個資料都有id
例如cache了10的資料,
當下次在開啟時,api 應該要更新哪些資料?第一頁?一到十頁?
似乎都不太對,
因此,試想了一下規則
1. 用一個Global 變數去儲存該api 已經拿到第n的頁數 (假設頁數為連續)
2. 離開app時(或剛進入app時),清除掉所有跟page api 有關的object
3. 如果設計需要,在離開該頁面時,清除掉所有跟page api 有關的object
造成的結果會是
在這次開啟app的狀況下,使用者會看到cache的結果,頁面資料只會拿一次(不會更新資料,因為global 變數去記錄該api已經拿到第幾頁)
在下次開啟該app 則會清除上次看過的資料,然後重新向server拿新資料
這樣應該可以解決大部分的問題吧
[iOS] Core Data 的 思
https://github.com/robbiehanson/XMPPFramework
XMPPFramework / Extensions / CoreDataStorage
中得到想法或靈感
其中比較重要的是
他利用多執行續去執行 core data (在 apple 的guide line 中其實不建議用多執行續去做)
我將這個方法套用在我現在的專案上
1. model control 動作後,會呼叫 sub thread 上的 NSManagedObjectContent (moc) 做動作
2. VC 上,用的是 Main thread moc 產生的 NSFetchedResultsController 來操縱 View
一開始看起來都還ok
不過最近卻發現一些問題
2013年11月15日 星期五
[other] Mac 重灌筆記
- 分割磁區
- 軟體
- Chrome
- Xcode
- 需要保留 4.6.3 & 5.0 (for iOS 5 模擬器)
- 可能在一陣子就不用測試 iOS 5
- profiles
- p12
- color plugin
- 輸入法
- yahoo輸入法
- MacHeist (Paid)
- fantastical
- CleanMyMac 2
- AirServer
- NotesTab
2013年11月5日 星期二
2013年11月4日 星期一
[ROR] rbenv and init initial env
原本用 RVM 想說用一下 rbenv看看
緣由 因為原本自學的時是使用的是 2.0.0 + ROR 4.0
但是上次的一個前輩的建議 使用 1.9.3 + ROR 3.2.15 會比較多資源
因為想說之後也有可能會遇到多版本的問題
舊先學習看看
http://edapx.com/2013/05/23/switching-from-rvm-to-rbenv/
https://github.com/sstephenson/rbenv
2013年9月21日 星期六
[ROR] heroku, postgres,
有在嘗試的 Paas
原本在試驗openshift ,不過在上傳啟動server的部份遇到的困難,我就轉去heroku看看
基本上我照著他的教學跑了一次
有遇到幾個問題
1. 網頁上app 的名稱
似乎給了一串預設的編碼
如果改了
就要記得執行
git config -e
把裡面的 git remote的位置改變
2. postgres
他們官方是建議使用postgres
我也在local端裝了
不過如過在 development 下 使用 postgres
會導致我必需把local 的username 給傳到git 上面
有點不想.... 實驗了很久,如果再mac 上在開一個使用者
好像還是有權限的問題
最後....我想說在development下用 sqlite就好了
Gemfile 寫下
# Use postgresql as the database for Active Record
group :production, :test do
gem 'pg'
end
group :development do
gem 'sqlite3'
end
然後
database.yml 就用
development:
adapter: sqlite3
database: db/development.sqlite3
pool: 5
timeout: 5000
==================
ROR 能做的設定參考:http://ihower.tw/rails3/environments-and-bundler.html
http://robdodson.me/blog/2012/04/27/how-to-setup-postgresql-for-rails-and-heroku/
http://www.fullybaked.co.uk/articles/getting-postgresql-running-on-osx-mountain-lion
http://www.moncefbelyamani.com/how-to-install-postgresql-on-a-mac-with-homebrew-and-lunchy/
2013年4月30日 星期二
[Mac server] 重新設定 server
因為我在清除機器裡面的舊資料
不曉得刪掉什麼東西
導致server 在登入app時一直登入不進去
刪掉server也似乎沒有清除掉舊的setting
正好有這篇
http://krypted.com/mac-os-x-server/hosed-your-mountain-lion-server-reset-it/
刪掉
sudo rm /var/db/.ServerSetupDone
就ok了
流程
1. 先用 appCleaner 刪掉 server.app
2. 在刪除 /var/db/.ServerSetupDone
3. 重新安裝 server.app
4. 開始重新設定
打完收工
2013年4月11日 星期四
[Jenkins] build for google map android Key
因為key store 綁電腦
所以developer 傳到git後,由jenkins下載,build 過後並無法顯示地圖,因為keystone不同
因此.... 要在jenkins 用ant 建立前
先換置掉 key store
script :
#!/bin/sh
# 步驟 (1/3)
DEVELOP_ANDROID_GOOGLE_API_KEY=XXXXXXXXX# 步驟 (2/3)
# 處理google map android api key 的問題
# 先用 google帳號 到google console申請 api key
# builder的 default.keystore的
# sha1 = XXXXXXXXX# 步驟 (3/3)
# 將申請到的 key 複製到下面的變數中
ANDROID_GOOGLE_API_KEY=XXXXXXXXX
# 換置動作
sed "s/$DEVELOP_ANDROID_GOOGLE_API_KEY/$ANDROID_GOOGLE_API_KEY/g" AndroidManifest.xml > AndroidManifest.xml.tmbuilderkeymv AndroidManifest.xml AndroidManifest.xml.tmp
mv AndroidManifest.xml.tmbuilderkey AndroidManifest.xml
以上應該就能暫時解決問題
(不過同時多個開發者應該還是會 …orz)
2013年4月10日 星期三
[Jenkins] MacOS + Jenkins 系統更新
1. app store 升級 MacOS
2. app store 升級 Xcode
(此時重開 後的 Jenkins 會是由 主要帳號開啟 )
3. 在主要帳號的 command line 下 執行 launchctl unload xxxxxxxxxx
4. 切換到 Jenkins 的帳號下
5. 在 command line 下 執行 launchctl load xxxxxxxxxx (不可以加入 sudo)
6. 開啟Jenkins網頁
7. 進入系統頁面下載新版本
8. 換置 .jar (注意 own & grp)
9. 在 command line 下 執行 launchctl unload xxxxxxxxxx
10. 在 command line 下 執行 launchctl load xxxxxxxxxx
11. 記得要加入 ssh-add 相關的 id
12. 記得把jenkins 下的 cashlytics 打開
打完收工.....
2012年11月21日 星期三
Jenkins + Unit Test
(下午遇到的問題是....可能要先在自己的mac上 make過 framework才能跑 我猜是 SDK的問題)
接著可能要解決的問題
1. ghunit 的 templete file
2. INSTALL OCMock + OCHAMCREST
3. run on the Jenkins
4. 以及最重要的..... 究竟要怎樣使用qq
他有遇到的我也有遇到耶!
http://www.egeek.me/2012/10/03/jenkins-ghunit-launch-msg-error/
Jenkins + GHUnit
http://www.tuicool.com/articles/uUbuUn
http://gabriel.github.com/gh-unit/docs/appledoc_include/guide_command_line.html
http://gabriel.github.com/gh-unit/docs/appledoc_include/guide_ci.html
======================================
一直卡在最後出 report 的地方
後來想說還是用官方的 OCUnit
感覺整合性還是好很多
再配合 OCUnit2JUnit
應該會不錯用
繼續努力....orz
http://www.raingrove.com/2012/03/28/running-ocunit-and-specta-tests-from-command-line.html
要先多建立一個 scheme
然後設定其關連性
script 用 https://gist.github.com/2410839
用 系統內的好像會一直出問題 (系統內好像是新的 anyway 至少舊的可以用....)
最後再 jenkins 上面的指令用:
xcodebuild -workspace xxxxx.xcworkspace -scheme xxxxx -sdk iphonesimulator5.1 -configuration Debug TEST_AFTER_BUILD=YES clean build
iphonesimulator5.1 不用 iphonesimulator 這樣預設好像是會用 6.0 好像會有 顯示視窗大小的問題....
finally ..... 我一直放錯重點 明明應該是要好好寫 Unit test , 卻一直放在產生 report 上
搞了一個下午+晚上+隔天早上 .... 終於弄出一個至少可以用的orz
時間真不夠用...QQ
other ref
http://www.gerardcondon.com/blog/2012/09/20/further-jenkins-setup-code-signing/
http://www.stewgleadow.com/blog/2012/02/09/running-ocunit-and-kiwi-tests-on-the-command-line/
http://hataewon.tumblr.com/post/30045666799/how-to-use-subprojects-with-xcode-and-jenkins
http://hataewon.tumblr.com/post/30327012898/continuous-integration-for-cocoa-using-jenkins-part-ii
Unit test example ?!?!
https://github.com/iamleeg/BrowseOverflow/tree/master/BrowseOverflowTests
2012年11月18日 星期日
CocoaPod 加入自己的 spec資料庫
https://github.com/CocoaPods/CocoaPods/wiki/Sharing-pod-specifications-with-yourself-and-the-world
指令
$ pod repo add my-spec-repo http://github.com/my-account/spec-repo.git
======== 我想應該是這樣用
https://github.com/CocoaPods/CocoaPods/wiki/Creating-and-maintaining-a-pod
先在自己的專案下 ex: xxxlib 下建立 一個 xxxlib.podspe
$ pod spec create xxxlib
接著編輯這個podsec
編輯後!!!
$ pod spec lint --local $ git add -A && git commit -m "Release 0.0.1." $ git tag '0.0.1' $ git push --tags
pod spec lint --local 只是先檢查格式對不對
接著commit 到git
然後加上tag
然後push到git server上
接著
$ pod push myspec
如果之前 有加入 pod repo add myspec xxxxx.git
那這裡就會自動更新 xxxxx.git server
然後接著 在重新載入到 seach list中
所以上面結束後再執行 pod search xxxlib
就可以看到他在 [myspec repo] 中了
2012年11月15日 星期四
Jenkins - android + ant + iOS + Xcode
Android 和 iOS的部份終於算是搞定大半了
iOS 在Build 的部份設定還算簡單
不過還沒有想過引用library的對應關係要怎樣設定 (因為我通常都是直接啦過去 這項好像很不好 orz)
不過最後 OTA的部份可能需要等 公司帳號申請下來再來做打算
Android 在build 的部份就花了一點時間搜尋
因為 Android在 Local端是用 Eclipse 來開發的
本身沒有直接產生 在Jenkins + ant 上面要用的build.xml
所以要利用 (ref - android)
./android update project -n ${JOB_NAME} -p ${WORKSPACE}
-n 會影響到產生的apk的名稱
-p 則是專案所在的資料夾
執行完後 就會產生一個build.xml
不過 可能有時會產生 叫你要輸入 --target 的選項
1. 首先要先檢查是否在Jenkins ref 到的 android SDK是否有 install 對應的api level
通常是上面的問題 因為沒有對應的api level 他會幫你檢查然後報錯
不過不要自己設定 --target,因為這是local 端已經寫好的 設定太多到時候其他專案重複利用性就會比較低了
接著是 如果這個android的專案有用到其他專案的jar
那 server 首先也要有對應的jar的專案
然後在 ant 的
| Properties |
sdk.dir=/Users/Shared/Jenkins/android-sdk-macosx
android.library.reference.1=../libfacebook-android/
android.library.reference.2=../easyclass-android/
....
這部份其實可以在 專案資料夾中的 project.properties 看到
不過因為local端的對應位置通常跟 server不同 所以可能需要重新設定對應位置
另外 android.library.reference.n 的規則 可以參閱(ref - android)
apk 的發佈也等到 網路比較快 再想想看
初期可能先用S3看看
2012年11月12日 星期一
Jenkins git ssh
https://confluence.atlassian.com/pages/viewpage.action?pageId=270827678#SetupSSHforGitandMercurialonMacOSX/Linux-enablessh
Step 4. Start the ssh-agent and load your keys
Users who work in OSX 10.6.8 or later have the option of skipping this step. Under OSX, the system asks for your connection parameters the first time you try to establish a connection. It also automatically starts the
ssh-agent for you at this time. |
ps -e | grep [s]sh-agent command to see if the agent is running:myhost:~ manthony$ ps -e | grep [s]sh-agent 9060 ?? 0:00.28 /usr/bin/ssh-agent -l
myhost:~ manthony$ ssh-agent /bin/bash
ssh-agent management program using the ssh-add command.$ ssh-add ~/.ssh/id_rsa Enter passphrase for /Users/manthony/.ssh/id_rsa: Identity added: /Users/manthony/.ssh/id_rsa (/Users/manthony/.ssh/id_rsa) myhost:~ manthony$
ssh-add command to list the keys that the agent is managing.$ ssh-add -l 2048 7a:9c:b2:9c:8e:4e:f4:af:de:70:77:b9:52:fd:44:97 /Users/manthony/.ssh/id_rsa (RSA)
2012年10月24日 星期三
Jenkins 2
http://blog.gasolin.idv.tw/2011/08/jenkinsandroid.html
http://blog.w3i.com/2012/08/08/continuous-build-and-deployment-for-ios-and-android-apps/
我大概照著這個方式做
先裝好 android sdk 然後下載一個 platform
接著 設定好權限
注意 他的 target api number
如果不對 記得要裝對應 或是換掉
target 的部份 給 clean release
Properties 記得給一下 sdk.dir=/Users/Shared/Jenkins/android-sdk-macosx
email 通知的部份可以設定附加檔案
不過可能想要改用其他的通知方法
另外
設定權限的部份 我不小心設定成 Legacy mode 導致一直近不去
不過可以透過 修改 %JENKINS_HOME%\config.xml 的檔案
修改掉 Legacy mode
另外重新啟動的方式是...
sudo launchctl unload /Library/LaunchDaemons/org.jenkins-ci.plist
sudo launchctl load /Library/LaunchDaemons/org.jenkins-ci.plist
2012年10月8日 星期一
Git something plus
A successful Git branching model
http://nvie.com/posts/a-successful-git-branching-model/
各式各樣的命令....
http://blog.longwin.com.tw/2009/05/git-learn-initial-command-2009/
用 git hub 的一些東西
http://gogojimmy.net/2012/01/17/how-to-use-git-1-git-basic/
http://git-scm.com/book/zh/ch1-4.html
可能要了解的branch
http://ihower.tw/blog/archives/2620/
可以多多看他的 觀念好多@@!
http://ihower.tw/blog/archives/category/git/
投影片!
http://www.slideshare.net/littlebtc/git-5528339
用 dropbox
http://www.mrmu.com.tw/2011/05/06/git-using-dropbox-as-server/
http://www.mrmu.com.tw/2011/05/06/git-tutorial-for-beginner/
原文書
http://git-scm.com/book
忽略檔案的東西
https://help.github.com/articles/ignoring-files
http://kevyu.blogspot.tw/2011/08/gitignore.html
Xcode 結合 GitHub
http://deeploveapple.blogspot.tw/2012/03/githubxcode.html (這篇我用不起來@@)
http://www.mindthe.net/devices/2011/04/28/12-steps-to-using-github-with-xcode-4/
