2012年12月22日 星期六

certificate identity iPhone developer: appears more than once in the keychain.the code sign tool requires there only be one.


certificate identity iPhone developer: appears more than once in the keychain.the code sign tool requires there only be one.


最快的方式是,把key chia上的所有憑證和鑰匙都砍掉,全部重做。
原因是,自己砍,也沒有砍完全。

全部重做時,連.p12也都要重做,重做後,回到Http://developer.apple.com裡,把所有專案也都重新下載。
要記得在Actions > Edit > Modify > Certificates裡,開發者要勾選,Sumit後才下載新的專案憑證。
Development 和 Distribution都要做呦!~

2012年12月19日 星期三

Xcode一張憑證,多台MAC使用

1.先在原開發機上下載當初製作的開發憑證。


2.把輸出的.p12放在雲端上(EX:DropBox)
輸出檔名為.p12,附檔名不要亂改名字呦!~



3.因為這張憑證很重要,所以請給他一個密碼保護他。
等等在另一台電腦上,會要打開他來用,所以不能忘記呦。

4.填入登入系統的密碼,按下允許。


/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

接下來換到另一台要當開發機的電腦上嘍!~

1.把「鑰匙圈存取」叫出來,檔案 > 輸入項目

2.到DropBox裡把剛剛存的.p12打開



3.輸入剛剛所填的保護檔案用的密碼。

4.這樣回到鑰匙圈主視窗後,在「憑證」裡就可以看到他了。







2012年12月18日 星期二

Xcode開發者憑證

1.先到鑰匙圈存取裡製作憑證。


2.輸入mail、名稱

3.按繼續做出.cer憑證。
4.到http://developer.apple.com登入開發者帳號
.在Certificates > Development,把剛剛的.cer上傳。

5.Distribution也把剛剛的.cer上傳哩



2012年12月13日 星期四

The model used to open the store is incompatible with the one used to create the store。


The model used to open the store is incompatible with the one used to create the store。
表示與目前現行版本的資料庫不同,要砍掉讓他自動產生新的。

連接JSON時,先看資料是Array?還是Dictionary?

連接JSON時,先看資料是Array?還是Dictionary?

[ Array

{Dictionary

JSON的資料
{ "NewBook": [ { "BookNo": "0104347 ", "BookName": "遇見街貓Bob ", "Author": "詹姆斯.伯恩 ", "Price": 290, "MemPrice": 229, "VipPrice": 220, "Url": "http://www.morningstar.com.tw/bookcomment-2.aspx?BOKNO=0104347", "ImgBig": "http://www.morningstar.com.tw/pic_m/0104347.jpg", "ImgSmall": "http://www.morningstar.com.tw/pic/0104347.jpg" },

    //最外層是Dictionary時,寫法用這樣。
     NSArray *json = [(NSDictionary *) [NSJSONSerialization JSONObjectWithData:responseData
     options:kNilOptions
     error:&error] objectForKey:@"NewBook"];
     
     
     
    
    
    //外層是Array就要用for去讀,每一輪讀取不同直,所以變數可以重複使用
    NSArray* json = [NSJSONSerialization JSONObjectWithData:responseData //1
                                                    options:kNilOptions
                                                      error:&error];
    
    dataArray = [NSJSONSerialization JSONObjectWithData:responseData //1
                                                options:kNilOptions
                                                  error:&error];
   for (NSDictionary *obj in json) {
        NSString *bookname =[obj valueForKey:@"BookName"];
        NSString *author   =[obj valueForKey:@"Author"];
        NSNumber *price    =[obj valueForKey:@"Price"];
        NSNumber *memprice =[obj valueForKey:@"MemPrice"];
        NSNumber *vipprice =[obj valueForKey:@"VipPrice"];

2012年12月4日 星期二

用FireFox使用Sqlite


- (NSPersistentStoreCoordinator *)persistentStoreCoordinator
{
    if (__persistentStoreCoordinator != nil) {
        return __persistentStoreCoordinator;
    }
    
    
    NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"MorningStar.sqlite"];
    
    NSLog(@"DB Path = %@", storeURL);

印出本機資料庫路徑

iMac/Library/Application Support/iPhone Simulator/6.0/Applications/50E9B8DB-0486-4BE7-9F7E-A87A04837756/Documents/MorningStar.sqlite

開啟FireFox>SQLite Manager
用開啟舊檔方式,把MorningStar.sqlite拉進SQLite Manager裡面,就可以編輯本機的Sqlite了。



讓Xcode幫你產生core_data_sample.xcdatamodeld的.h .m檔


讓Xcode幫你產生core_data_sample.xcdatamodeld的.h  .m檔。

點選專案資料夾,右鍵>New File






選iOS>Core Data>NSManagedObject subclass,之後都下一步完成。



就會在專案資料夾中出現Focus.h  Focus.m





[CoreData]當本機還沒有產生sqlite時,這段程式先註解掉。


在AppDelegate.m裡,當本機還沒有產生sqlite時,這段程式先註解掉。
先讓前段程式執行生成。


 // 載入資料
    /*
    if (![[NSFileManager defaultManager] fileExistsAtPath:[storeURL path]]) {
        NSURL *preloadURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"MorningStar" ofType:@"sqlite"]];
        NSError* err = nil;
        
        if (![[NSFileManager defaultManager] copyItemAtURL:preloadURL toURL:storeURL error:&err]) {
            NSLog(@"Oops, could copy preloaded data");
        }
    }
    */