2012年12月18日 星期二

iOS 第三方函式庫



http://www.uml.org.cn/mobiledev/201212052.asp

有些在慢慢整合進去




MagicalRecord

  • 這個會在project 端被引入,他似乎沒有支援多個CoreData
  • 所以,現在可能在General Lib 用的是原生的方法,
  • project端就使用他的lib 看準的是他的icloud 的功能
  • 決定還是不使用這個lib,單一功能可能很方便,不過如果library要轉移的時候可能會比較麻煩


MBProgressHUD

iOS - UI - Move Button

http://www.cocoanetics.com/2010/11/draggable-buttons-labels/



- (void)viewDidLoad 
{
    [super viewDidLoad];
 
 // create a new button
 UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
 [button setTitle:@"Drag me!" forState:UIControlStateNormal];
 
 // add drag listener
 [button addTarget:self action:@selector(wasDragged:withEvent:) 
  forControlEvents:UIControlEventTouchDragInside];
 
 // center and size
 button.frame = CGRectMake((self.view.bounds.size.width - 100)/2.0,
   (self.view.bounds.size.height - 50)/2.0,
   100, 50);
 
 // add it, centered
 [self.view addSubview:button];
}
 
- (void)wasDragged:(UIButton *)button withEvent:(UIEvent *)event
{
 // get the touch
 UITouch *touch = [[event touchesForView:button] anyObject];
 
 // get delta
 CGPoint previousLocation = [touch previousLocationInView:button];
 CGPoint location = [touch locationInView:button];
 CGFloat delta_x = location.x - previousLocation.x;
 CGFloat delta_y = location.y - previousLocation.y;
 
 // move button
 button.center = CGPointMake(button.center.x + delta_x,
  button.center.y + delta_y);
}

2012年12月16日 星期日

AWS ssh login



1.  記得要打開  ssh 的 port
     設定一個security Group




2. 加入一個 key pair





3. console mode 下打入

ssh -v -i xxxx.pem root@ec2-xx-xx-xx-xx.compute-1.amazonaws.com

2012年12月13日 星期四

iOS keychain

http://blog.csdn.net/yiyaaixuexi/article/details/7688745


通常情况下,我们用NSUserDefaults存储数据信息,但是对于一些私密信息,比如密码、证书等等,就需要使用更为安全的keychain了。keychain里保存的信息不会因App被删除而丢失,在用户重新安装App后依然有效,数据还在。
使用苹果官方发布的KeychainItemWrapper或者SFHFKeychainUtils很方便,后来看到 iphone使用keychain来存取用户名和密码 一文,觉得对了解keychain有很大的帮助,于是ARC控也尝试了一把。
需要导入Security.framework 

iOS XML Library 的選擇

http://blog.csdn.net/yiyaaixuexi/article/details/7894577



iOS平台XML解析类库对比和安装说明

在iPhone开发中,XML的解析有很多选择,iOS SDK提供了NSXMLParser和libxml2两个类库,另外还有很多第三方类库可选,例如TBXML、TouchXML、KissXML、TinyXML和GDataXML。问题是应该选择哪一个呢?
解析 XML 通常有两种方式,DOM 和 SAX:
  • DOM解析XML时,读入整个XML文档并构建一个驻留内存的树结构(节点树),通过遍历树结构可以检索任意XML节点,读取它的属性和值。而且通常情况下,可以借助XPath,直接查询XML节点。
  • SAX解析XML,是基于事件通知的模式,一边读取XML文档一边处理,不必等整个文档加载完之后才采取操作,当在读取解析过程中遇到需要处理的对象,会发出通知对其进行处理。
一般在iOS平台下,比较常用的XML解析类库有如下几种:

又是強者!

http://www.imobileappsoft.com/home/whatisappneeded

http://itouchs.blogspot.tw/2011/09/lalas-program-note-31-core-data.html

http://blog.csdn.net/yiyaaixuexi/article/category/1088832

2012年12月9日 星期日

xmpp + p2p


1. libjingle 移植到 iOS 上並不順利 …. 問題相當的多 …. 不過… 似乎正好有人有移植好的 https://github.com/openpeer/OPiOS  但是好像才剛開始....  範例等等的都還有點弱… open peer
http://hookflash.com/platform/open-peer/   好像要錢@@

2. 另外是自行實踐  peerconnect   https://developers.google.com/talk/libjingle/libjingle_applications#connecting
XMPP 只是負責溝通.... 影音串流最後還是走p2p

3. gtalk 在 video上的protocol ?! https://developers.google.com/talk/call_signaling?hl=zh-TW
如果需要的話 可能需要實踐他?!
https://developers.google.com/talk/open_communications?hl=zh-TW
Details on the voice and video signaling used by Google Talk are available in the Google Talk Call Signaling document. Additionally, the open source libjingle library is provided to make it easy to implement voice/video interoperability with Google Talk.
(如果能用 …. 最快的方式還是使用 libjingle 會比較正確有效)
(使用上可能需要參考… https://developers.google.com/talk/libjingle/index?hl=zh-TW)


4. WebRTC 還不是很懂....先記錄  http://www.webrtc.org/reference/native-apis#TOC-Class-VideoTrackInterface
如果單看 demo  大概可以猜到是一些瀏覽器可以應用到的技術.... http://www.webrtc.org/running-the-demos

wiki XMPP Jabber

大陸資源 ....


http://wiki.jabbercn.org/RFC3921


http://zh.wikipedia.org/wiki/XMPP

http://www.w3.org/TR/webrtc/  

http://dev.w3.org/2011/webrtc/editor/getusermedia.html#intro



http://chloerei.com/2010/05/10/xmpp-base-II/   這一篇的講解還蠻仔細的!


在即时聊天 (IM) 应用中,客户端登录服务器后做的第一个操作通常是获取联系人列表。获取联系人列表需要发送 get 类型的 Iq 数据包。(Iq数据包将会在3.6节解释)
客户端:
<iq from='juliet@example.com/balcony' type='get' id='roster_1'>
    <query xmlns='jabber:iq:roster'/>
</iq>
该请求的意义为:名为 juliet 的用户 (登录资源为 balcony) 向 example.com 服务器请求获得 (get) roster 表。
服务器收到请求后,返回 roster 表。
服务端:
<iq to='juliet@example.com/balcony' type='result' id='roster_1'>
    <query xmlns='jabber:iq:roster'>
        <item jid='romeo@example.net'
            name='Romeo'
            subscription='both'>
            <group>Friends</group>
            </item>
        <item jid='mercutio@example.org'
            name='Mercutio'
            subscription='from'>
            <group>Friends</group>
            </item>
        <item jid='benvolio@example.org'
            name='Benvolio'
            subscription='both'>
            <group>Friends</group>
        </item>
    </query>
</iq>
可以看到,juliet 的 roster 表内有3个联系人,分别名为 Romeo,Mercutio,Benvolio,都属于 Friends 分组。Roster 列表中的 JID 信息将会用在稍候客户端发送信息包的目的地址中。

Item 中的 subscription 关系到联系人状态信息的传输,有 none,both,from,to 四种。详细的 subscription 操作在 RFC 3921 Managing Subscriptions 章节[7]中定义。


http://xmpp.org/xmpp-protocols/xmpp-extensions/    xmpp 擴充的列表 .....


應該是用 peerconnection_server + https://code.google.com/p/libjingle/source/browse/#svn%2Ftrunk%2Ftalk%2Fexamples%2Fpeerconnection%2Fclient
1不過似乎還是有點麻煩


2012年12月8日 星期六

iOS app store 大陸版攻略

http://www.cocoachina.com/appstore/top/2012/1206/5275.html



感谢社区会员ifunway的分享
本文是社区里App Store相关文章的综合整理,不是中规中矩的教程,多是大家亲身实战经验,也希望各位多多分享自己的心得体会。如另一位会员mqiezi说的那样:你的一小步,可能就是别人的一大步。
总结各位前辈的优秀原创,我整理出来,方便大家查找。感谢各位,本贴持续更新 有好文请推荐!
申请IDP
个人帐户申请
苹果开发者帐户,详细图文教程
http://www.cocoachina.com/bbs/read.php?tid-13372.html
企业帐户申请
【D-U-N-S 号申请最新流程】(心得) 
http://www.cocoachina.com/bbs/read.php?tid=113741
App Store经验心得
开发者与新App Store[转]
http://www.cocoachina.com/bbs/read.php?tid=128396
在App Store 上的一些推广经验,希望对大家有帮助
http://www.cocoachina.com/bbs/read.php?tid-68578.html
Appstore 2012 改版之我见
http://www.cocoachina.com/bbs/read.php?tid=125588
申请技巧
注意谨慎使用他人信用卡付费
http://www.cocoachina.com/ask/questions/show/58466
没有办法发国际传真怎么操作?
http://www.cocoachina.com/bbs/read.php?tid=28047 

一家之言
陈林:如何发现创意:
http://www.cocoachina.com/bbs/read.php?tid=99321&fpage=2 
oyefaction:从《iZumas爱死祖玛》看名字对排名的重要性
http://www.cocoachina.com/bbs/read.php?tid=66099
陈林:一个图标换了50万下载量
http://www.cocoachina.com/bbs/read.php?tid=108275

创业经历
iPhone独立开发者没有神话,只有故事 
http://www.cocoachina.com/bbs/read.php?tid=102268&fpage=2
小猪的创业经历 ios developer 一年祭[2011.10---2012.09]
http://www.cocoachina.com/bbs/read.php?tid=114792&fpage=2 

广告平台
提醒大家,谨慎使用inmobi广告平台
http://www.cocoachina.com/bbs/read.php?tid=78546

数据参考
Fwish:美国中国top 1的下载量
http://www.cocoachina.com/bbs/read.php?tid=48351
Lv1CC: 美国等大区Store Top Paid&Grossing的数据
http://www.cocoachina.com/bbs/read.php?tid=75546

限时免费
限时免费不可不知的秘密
http://www.cocoachina.com/bbs/read.php?tid=55765 

四点解密苹果 6月 最新搜索算法
http://www.cocoachina.com/bbs/read.php?tid=107904 

代理发行
autinhorse:我们和Chillingo合作发行的经验教训
http://www.cocoachina.com/bbs/read.php?tid=116368

销售数据
Newpro:2012销售额
http://www.cocoachina.com/bbs/read.php?tid=128210 

爱死祖玛和合金力量,每天大概有700-800刀的广告收入
http://www.cocoachina.com/bbs/read.php?tid=123626

年结......(今年的收入主要来自三方面:Apple 、Admob以及其他广告商)
http://www.cocoachina.com/bbs/read.php?tid=128210


2012年12月7日 星期五

sig/slot

大學沒好好的學.... 只好有空看看對岸的牛人...orz


http://blog.csdn.net/smallcraft/article/details/2237802


 

Sigslot介紹

分類: C/C++學習2812人閱讀 評論 (3) 收藏 舉報
  最近在開發一個基於libjingle開源的IM系統,裡面有一個其類為has_slots,搜索了一下其資料發現是一個很好用的C++庫,先對其簡單介紹一下。
1.          簡介
      sigslot是一個線程安全、類型安全,用C++實現的sig/slot機制(sig/slot機制就是對象之間發送和接收消息的機制)的開源代碼庫。是一個非常好用的庫,只有一個頭文件sigslot.h。
2.    Sigslot實例
      現代的C++項目通常包含大量的C++類和對象,對象之間通過成員函數調用,缺點是當類和對象規模很大時,相互之間必須記住對方提供了哪些接口,以及接口的詳細信息,很不方便。
比如:我們有一個switch類和一個light類,而我們現在需要將兩者關聯起來,即通過switch控制light的狀態,我們可能需要添加一個另外的類ToggleSwitch來將兩者關聯起來:
class Switch
{
public:
     virtual void Clicked() = 0;
};
class Light
{
public:
     void ToggleState();
     void TurnOn();
     void TurnOff();
};
class ToggleSwitch : public Switch
{
public:
     ToggleSwitch(Light& lp){m_lp = lp;}
     virtual void Clicked(){m_lp.ToggleState();}
private:
     Light& m_lp;
};
Light lp1, lp2;
ToggleSwitch tsw1(lp1), tsw2(lp2);
這在功能上完全可以實現,但想像一下如果大量的需要相互交互消息的類,那工作量就不是一般的大了。 
使用sig/slot機制來解決上述情況,不需要關心關聯類的接口細節,sigslot實現的switch和light上述功能如下:
class Switch
{
public:
     signal0<> Clicked;
};
class Light : public has_​​slots<>
{
public:
     void ToggleState();
     void TurnOn();
     void TurnOff();
};
Switch sw1, sw2;
Light lp1, lp2;
   
     Sigslot機制實現該功能與第一種方法相比,switch類多了個signal0成員,light類需要從has_slots<>繼承,其他沒有什麼變化,但省去了編寫繼承類用來實現兩者關聯的ToggleSwitch 。
下面是實現功能的簡單代碼。
 
#include <iostream>
using namespace std;
 
#include "sigslot.h"
using namespace sigslot; //必須加上sigslot的命名空間
//在用vs調試時還需要將sigslot.h中很多的自定義模板結構類型前加typename
const int TRUE = 1;
const int FALSE = 0;
class Switch
{
public:
       signal0<> Clicked;
//這裡的信號是不帶參數的,signaln表示帶幾個參數
};
class Light : public has_​​slots<>
{
public:
       Light(bool state){b_state = state;Displaystate();}
       void ToggleState(){b_state = !b_state;Displaystate();} //作為消息的響應
       void TurnOn(){b_state = TRUE;Displaystate();}
       void TurnOff(){b_state = FALSE;Displaystate();}
       void Displaystate(){cout<<"The state is "<<b_state<<endl;}
private:
       bool b_state;
};
void main()
{
       Switch sw1, sw2,all_on,all_off;
       Light lp1(TRUE), lp2(FALSE);
       sw1.Clicked.connect(&lp1,&Light::ToggleState); //綁定
       sw2.Clicked.connect(&lp2,&Light::ToggleState);
       all_on.Clicked.connect(&lp1,&Light::TurnOn);
       all_on.Clicked.connect(&lp2,&Light::TurnOn);
       all_off.Clicked.connect(&lp1,&Light::TurnOff);
       all_off.Clicked.connect(&lp2,&Light::TurnOff);
 
       sw1.Clicked();
       sw2.Clicked();
       all_on.Clicked();
       all_off.Clicked();
 
       sw1.Clicked.disconnect(&lp1);
       sw2.Clicked.disconnect(&lp2);
       all_on.Clicked.disconnect(&lp1);
       all_on.Clicked.disconnect(&lp2);
       all_off.Clicked.disconnect(&lp1);
       all_off.Clicked.disconnect(&lp2);
}
 
 
  。  參數類型
        sig/slot可以帶參數也可以不帶,最多可以帶8個參數。重新回顧上例,switch類的signal0<> Clicked,稱之為sig,即用來發出信號;而繼承has_slots<>的類light的成員函數void ToggleState() Turnon() Turnoff(),稱之為slot ,即信號的處理函數。sigslot的核心就在這裡,就是通過這兩個建立對應關係來實現對象間的消息交互。
sig是一個成員變量,它形如
 
signal+n<type1,type2……>
    後面的n表示signal可以接收幾個參數,類型任意,最多為8個。這是由庫中指定的,當然如果實際開發需要更多的參數,可以修改sigslot庫。
slot是一個成員函數,它形如:
void SlotFunction(type1,type2……)
   需要記住:slot的類必須繼承has_slots<>;成員函數的返回值必須為void類型,這是這個庫的局限性,當然如果實際開發需要返回值,也是可以修改sigslot庫來實現。此外還需要注意的是slot的原形需要與sig一致。怎麼說呢,就是signal只能與帶有與它相同參數個數的slot函數進行綁定,而且signal的參數是直接傳遞給slot的。
 
4.    Sigslot庫用法
發送信號
信號(sig,即sig/slot的sig,下面提到的信號等同於此含義):
signal1<char *, int> ReportError;
比如上面的一個ReportError這個信號,當調用ReportError("Something went wrong", ERR_SOMETHING_WRONG);時候,將自動調用ReportError的emit成員函數發出一個信號。發給誰呢?
 
連接信息號
通過調用sig的connect函數建立sig和slot間的對應關係。Connect函數接收兩個參數,一個是消息目的對象的地址(指針),另一個是目的對象的成員函數指針(slot)。為了讓整個機制有效運行,目的類必須從has_slots<>繼承,並且sig/slot參數類型必須一致。也可以將一個sig連接到多個slot上,這樣每次sig發出信號的時候,每個連接的slot都能收到該信號。
 
斷開信號連接
通過調用sig的disconnect函數斷開sig和slot之間的連接,只有一個參數:目的對象的地址。一般不需要顯式調用disconnect函數,在sig類和目的類(包含slot函數的類)析構函數中將自動調用disconnect斷開sig和slot的連接。也可使用disconnect_all斷開該sig的所有slot。
all_on.Clicked.connect(&lp1,&Light::TurnOn);
all_on.Clicked.connect(&lp2,&Light::TurnOn);//同上
all_on.Clicked.disconnect_all();
 

XMPP - Gtalk - iOS

.....這個真的不是普通麻煩....

我真弱....

先不管.... 先把找到的資訊整理整理...

source : http://code.google.com/p/libjingle/

照著 readme 就行了... 不過有空在來整理一下

other resource : https://github.com/vigsterkr/libjingle

https://github.com/healthkxy/libjingle-ios/tree/master/talk

https://github.com/angad/libjingle-mac

https://github.com/alist/libjingle_ios


現在主要遇到的問題反而還沒有到xmpp的主問題上

 example 似乎跑步起來...orz




觀念:
http://blog.csdn.net/leehark/article/details/7216914

http://blog.csdn.net/kaka11/article/details/4807837


可能會用到的資源

http://code.google.com/p/chromium/wiki/MacBuildInstructions

http://code.google.com/p/chromium/wiki/Clang

https://groups.google.com/forum/#!topic/discuss-webrtc/bMP5Dm79FaQ

http://blog.csdn.net/shencaifeixia1/article/details/7801585

http://www.bluehands.de/software/beat/myjingle/

2012年12月6日 星期四

iOS create in-app-purchase

1. 先產生一個 app 到 itunes store 上

2. 到 manage app , 點選所屬的app

3. 點選  manage in-app-purchase    
















4. create new one


    reference name: 內部顯示用

   productID: 程式內會用到,用來辨別這項產品的編碼像我是用com.mycompany.appname.iap_product

cleared for Sale :不確定幹嘛的,不過好像是開關這項產品是不是被販賣

price tier  :  價錢嚕,不過好像一樣可以設定時間區段


language 部分 是主要顯示給使用者看的,

Hosting content with apple :似乎是iOS6的功能,托管一些買了之後要下載的內容資料給apple的server  可以看另一篇網誌有提到別人講的....


PS.  在這之前 需要到  Contracts, Tax, and Banking  填入一些聯絡資料,銀行資料等等...

    並且簽署另一份協議  才能正式的使用

5.  設定好了之後就可以到 Manage Users  新增測試帳號

     這樣在就可以在app 中測試了

     測試的時候 購買的alert下方會顯示  [environment: sandbox] 之類的字眼

iOS create app on itune store


1. 先要有一個apple的帳號,且付過錢

2. 登入iTunes store

3. manage your app -> Add New app

4.
app name :顯示在app store中
sku number : 這個算是這個帳號內部使用的一個編碼,在你的帳號內會是唯一,我在想可能是報表上看的到,應該是拿來識別你的這個專案
Bundle ID : 如果不知道應該也不用送審了XD

PS. app name 打了之後 似乎會被保留一段時間(即使刪除掉),我記得看過一篇是寫 120 days,... anyway, 盡量別設錯內容,不然要改很麻煩...

PS.  sku number 似乎也會被保留,不過不確定是多久

5.


這裡會要輸入你要的價格,以及價格時間區段
基本上可以輸入多組,我沒有實驗過,有試過在留一下記錄

Discount for Educational Institutions 有沒有提供教育折扣,我也不曉得折多少

Custom B2B App 還沒有研究過
6.

接下來這部份就是填一些app 的基本資料

還有rating  就是填一些app 有沒有暴力內容等等  ,來鑒定你的app的年齡分別

假設你有額外的用戶許可協議 (only text, not html)
可以寫入文字到 EULA




iOS The Information Property List File

http://developer.apple.com/library/ios/#documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/App-RelatedResources/App-RelatedResources.html#//apple_ref/doc/uid/TP40007072-CH6-SW4



2012年12月5日 星期三

iOS iTunes Hosting Content with Apple

http://stackoverflow.com/questions/11028183/whats-hosting-content-with-apple

This is a new feature with iOS 6, you can have apple host your content, such as images and videos. If you are looking to support anything below iOS6, then you should select no (assuming you have content that needs to be hosted), if your in app purchase does not need to download anything, then just select no.

2012年12月3日 星期一

App Store info.plist

https://developer.apple.com/library/ios/#documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/BuildTimeConfiguration/BuildTimeConfiguration.html



Table 5-1  Dictionary keys for the UIRequiredDeviceCapabilities key
Key
Description
accelerometerInclude this key if your app requires (or specifically prohibits) the presence of accelerometers on the device. Apps use the Core Motion framework to receive accelerometer events. You do not need to include this key if your app detects only device orientation changes.
armv6Include this key if your app is compiled only for the armv6 instruction set. (iOS 3.1 and later)
armv7Include this key if your app is compiled only for the armv7 instruction set. (iOS 3.1 and later)
auto-focus-cameraInclude this key if your app requires (or specifically prohibits) autofocus capabilities in the device’s still camera. Although most developers should not need to include this key, you might include it if your app supports macro photography or requires sharper images in order to perform some sort of image processing.
bluetooth-leInclude this key if your app requires (or specifically prohibits) the presence of Bluetooth low-energy hardware on the device. (iOS 5 and later.)
camera-flashInclude this key if your app requires (or specifically prohibits) the presence of a camera flash for taking pictures or shooting video. Apps use theUIImagePickerController interface to control the enabling of this feature.
front-facing-cameraInclude this key if your app requires (or specifically prohibits) the presence of a forward-facing camera. Apps use the UIImagePickerControllerinterface to capture video from the device’s camera.
gamekitInclude this key if your app requires (or specifically prohibits) Game Center. (iOS 4.1 and later)
gpsInclude this key if your app requires (or specifically prohibits) the presence of GPS (or AGPS) hardware when tracking locations. (You should include this key only if you need the higher accuracy offered by GPS hardware.) If you include this key, you should also include the location-services key. You should require GPS only if your app needs location data more accurate than the cellular or Wi-fi radios might otherwise provide.
gyroscopeInclude this key if your app requires (or specifically prohibits) the presence of a gyroscope on the device. Apps use the Core Motion framework to retrieve information from gyroscope hardware.
location-servicesInclude this key if your app requires (or specifically prohibits) the ability to retrieve the device’s current location using the Core Location framework. (This key refers to the general location services feature. If you specifically need GPS-level accuracy, you should also include the gps key.)
magnetometerInclude this key if your app requires (or specifically prohibits) the presence of magnetometer hardware. Apps use this hardware to receive heading-related events through the Core Location framework.
microphoneInclude this key if your app uses the built-in microphone or supports accessories that provide a microphone.
opengles-1Include this key if your app requires (or specifically prohibits) the presence of the OpenGL ES 1.1 interfaces.
opengles-2Include this key if your app requires (or specifically prohibits) the presence of the OpenGL ES 2.0 interfaces.
peer-peerInclude this key if your app requires (or specifically prohibits) peer-to-peer connectivity over a Bluetooth network. (iOS 3.1 and later)
smsInclude this key if your app requires (or specifically prohibits) the presence of the Messages app. You might require this feature if your app opens URLs with the sms scheme.
still-cameraInclude this key if your app requires (or specifically prohibits) the presence of a camera on the device. Apps use the UIImagePickerControllerinterface to capture images from the device’s still camera.
telephonyInclude this key if your app requires (or specifically prohibits) the presence of the Phone app. You might require this feature if your app opens URLs with the tel scheme.
video-cameraInclude this key if your app requires (or specifically prohibits) the presence of a camera with video capabilities on the device. Apps use theUIImagePickerController interface to capture video from the device’s camera.
wifiInclude this key if your app requires (or specifically prohibits) access to the networking features of the device.

iOS app 名稱顯示

http://kelp.phate.org/2012/01/localize-app-name-infopliststrings.html