2016年7月28日 星期四

swift 語言一些心得

這其實是1.0的心得,現在已經出到3.0了 其實這份也不用看細節了,直接看一些特別的語法特性就好了。

https://drive.google.com/file/d/0B6BL3rjr8LORb3ptY2g0a3ZpQVE/view?usp=sharing

2016年6月12日 星期日

CAMediaTimingFunction

Basically I want to make a dots animation view like this.


So I look into the CAMediaTimingFunction and it's a bezier function.

https://en.wikipedia.org/wiki/B%C3%A9zier_curve

There is a website that you can view your bezier curve in CAMediaTimingFunction

http://netcetera.org/camtf-playground.html

So I just create 3 dots with different CAMediaTimingFunction that changes alpha like this.




But eventually it don't really have to use CAMediaTimingFunction to approach this. Just create animation groups will be more precise.


2016年6月2日 星期四

iCloud Key-value storage development


The goal is store your app preference to iCloud for backup. That only involved to the key-value storage of iCould.

To use iCloud in an app. You need to configure the in the apple develop like this





Where you can store different type of data like .


Which only key-value storage don't need a container, others are needed a container to store the data in. Look into the apple document would be more helpful.

iCloudDesignGuide

Once you setup the iCould, you could be able to access NSUbiquitous store


    [NSUbiquitousKeyValueStore defaultStore]

and store your key-value data like UserDefault to the ubiquitouskeyvaluestore
  
    [[NSUbiquitousKeyValueStore defaultStore] setObject:obj forKey:key];
    [[NSUbiquitousKeyValueStore defaultStore] synchronize];


and you register a notification of the key
NSUbiquitousKeyValueStoreDidChangeExternallyNotification


And analysis the notification you will get the key-value backup from your iCould account.

    NSDictionary *userInfo = [notificationObject userInfo];
    NSInteger reasonForChangeValue = [[userInfo objectForKey:NSUbiquitousKeyValueStoreChangeReasonKey] integerValue];
        
     if (reasonForChangeValue == NSUbiquitousKeyValueStoreInitialSyncChange)
    {
          // your merge code here
    }


That's it.
You can take look into the
https://github.com/hydrated/iOS-Utilities/tree/master/iCouldSync 


Furthermore you want to make more functionality,
NSUbiquitousKeyValueStoreChangeReasonKey has 4 values can be listening notification. like account change , violate limitation storage.


2015年6月25日 星期四

UITableView and ListView in Polymorphism

UITableView and ListView都有dequeue cell and item的作用,一些心得,

可使用autolayout
_mainTableView.estimatedRowHeight =  44;

_mainTableView.rowHeight = UITableViewAutomaticDimension;

一個tableview的cell會保持自己的instance,你無法取代新的instance該裡面的cell,尤其UIWebView塞進cell更是難以計算高度,用之前千萬三思。


Android ListView更為複雜,一個getView會call三次左右才決定一個item,我設計了一個polymorphism 的架構來控制items


interface {

    public abstract int getType();
    public abstract void setViewHolder(View convertView);
    public abstract void inflateViewHolder(View convertView);
    public abstract View getTemplateView(ViewGroup parent);

}



@Override
public int getItemViewType(int position) {
    return ((interface) getItem(position)).getType();
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {

    final int type = getItemViewType(position);

    if (convertView != null) {
        mList.get(position).inflateViewHolder(convertView);
    } else {
        convertView = mList.get(position).getTemplateView(parent);
        mList.get(position).setViewHolder(convertView);
    }

return convertView;

}

mList必須保持所有子item的data instance,注意只有data不存view,那麼getItemViewType內的gettype決定你item type,之後需傳入convertView給該子item作render。以及null的情況下new一個新的instance view給convertView。

目前使用起來沒出問題,listview item開兩萬個也無礙,我想應該是可行的。

2015年5月27日 星期三

git xcode merge branch xcodeproj/project.pbxproj conflict的解法

這檔案控管project檔案的,多人開發會有衝突,小型project還能用人力自行merge,太大就難了,我是使用這github的script當mergetool

https://github.com/simonwagner/mergepbx

此外多人開發storyboard也是個issue,我目前並沒有merge的方法,只能從切畫面當xib來使用。

2015年3月11日 星期三

使用Reveal破解任意iOS app view hierarchy

Reveal這套軟體可以用來破解任意iOS app view hierarchy,內容應該正確 這我沒辦法確認

參考網路上的文章 http://c.blog.sina.com.cn/profile.php?blogid=cb8a22ea89000gtw 雖然只有六步,但這六步其實都不簡單。 


1. Jailbreak過後的裝置,這步只能你自己想辦法了,通常照ios等級會有不同的方法。

2. 安裝reveal,找出裡面的libReveal.dylib,並且安裝至mobile內的/Library/MobileSubstrate/DynamicLibraries 


reveal選menu的help/show reveal library in finder就有libs了


JB過後的device會有Cydia,Cydia內可以安裝openssh,需等Cydia自己更新後才搜尋的到,網路上說可以加入Repo http://weamdev.org/repo,但我還沒找到加入法就可以安裝openssh了。 


而後需要安裝Cydia substrate後,/Library/MobileSubstrate/DynamicLibraries才會出現 我是透過scp將檔案裝入,並且加入一個file named 'libReveal.plist'
{ Filter = { Bundles = ( "com.yourdomain.yourapp" ); }; } 

其中bundle name如果是他人app,則你還需在itunes中自行下載他的app,而後在你的硬碟裡找出 ~/Music/iTunes/iTunes Media/Mobile Applications/ 這目錄下你下載的.ipa,更名至.zip。

unzip後,在iTunesMetadata.plist中找出key softwareVersionBundleId
<key>softwareVersionBundleId</key>

<string>"XXXXXXX"</string>

其中XXXXXXX則為你需要的bundle name 

3. 重開設備或者re-spring(我不會),而後你就可以在Reveal中享受你的成果了。



還需注意的是,JB過的安裝openSSH device最好換掉root密碼,預設為alpine


2014年11月9日 星期日

NFC in Android

All my informations learned from this book

Professional NFC Application Development for Android – Vedat Coskun, Kerem Ok, busra Ozdenizci

I recommended developers in NFC Android to buy one, no matter app layer or driver layer.
It helps me learning from no basic knowledge in hardware to fully understand NFC technology in Android.
Some of my document sentences make no sense because all figures are in the book.
You have to buy one of find it out on the internet.

https://drive.google.com/file/d/0B6BL3rjr8LORVEpHYkJmdVdhMG8