2013年5月20日 星期一

iOS 5,iOS 6 自動旋轉設定

iOS 5 和 ios6 兼容的自動旋轉設定有點坑人..

首先,專案設定有可支援方向

這設定是全域性的,整個 app 能支援的方向都在這邊設定

但是個別的 VC 旋轉設定要在各 VC 中自行設定

而 iOS 5, iOS 6 的設定方法並不相同

iOS 5

- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {

//檢查是否為可旋轉方向

}

// 設定旋轉後配置,可用其他方法

- (void) didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {

// in iOS statusBarOrientation is correct than all other orientation changes

if(UIDeviceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation))

self.view.frame = CGRectMake(0,0,1024,768);

else

self.view.frame = CGRectMake(0,0,768,1024);

}

iOS 6

如果每個 VC 都要旋轉,就算了

如果不是,在最底層的 VC 要先設定如下方法,禁用自動旋轉

- (BOOL)shouldAutorotate {

return NO;

}

然後在需要旋轉的 VC 使用

- (BOOL)shouldAutorotate{

return YES;

}

- (NSUInteger)supportedInterfaceOrientations{

return UIInterfaceOrientationMaskAllButUpsideDown;

}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{

return UIInterfaceOrientationLandscapeRight;

}

此外,在 ios 6 底下

window 需要设置 rootViewController,[window addSubview:navController.view]; 无效;

shouldAutorotate 在最底层设置才有效;

presentModalViewController 下用之前的自动旋转控制无效,须用 category 解决。

參考資料

http://fann.im/blog/2012/10/22/autorotation-changes-in-ios-6/

2013年5月16日 星期四

jqtouch animation failed on iPhone 5

恭喜那些衰到要修改 2009/11 jqtouch 版本在 iphone5 上動畫的人

Gratz to those doomed to correct jqtouch (version around 2009/11 around) and lucky reach here

jqtouch (2009/11) 版本在 iphone 5 上面有一些奇怪的問題

例如 slide 動畫在 iPhone 4 上面可以正常運作

但是在 iphone 5 上面不行

jQTouch has some weird animation behavior on iPhone 5

kind of slide animation works fine on iPhone 4 but not iPhone 5

處理的方法很簡單也很詭異

對不正常運作的方法綁定一個無意義動作即可

例如

if’s wasy to correct in a weird way..

bind these link button an animation event with meaningless action,

sort like:

$(‘#somediv’).bind(‘pageAnimationStart’, function(){

        $(‘somediv’).text($(‘somediv’).text());

});

$(‘#somediv’).bind(‘pageAnimationEnd’, function(){

        $(‘somediv’).text($(‘somediv’).text());

});

這看起來像是jQTouch 對於有事件的 div 執行動畫時的方法不同

不過因為這版本實在太舊了,懶得深入去追查

因此就模仿其他綁定動畫事件後正常的div 進行類似的動作

I guess this comes from jQTouch (2009/11 version) handles animation in different way with those bind page animation compared to those without binding.

Since this version is just too old, I don’t wanna spend lots time to track and find the bug, I decide to copy the actions from behave fine to those behave badly, and here is the result..

Quite easy code, spend 2 days tho.. because I tried lots normal solution on them but failed orz

2013年5月14日 星期二

cocoa 字元編碼

這幾天在處理一個登入介面

不過傳送密碼時碰到問題了

由於密碼中有特殊字元,諸如 @+等字元

而這些字元在 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding 中並不會被編碼

所以 server 端收到後,會有處理上的問題

因此必須強制編碼

http://stackoverflow.com/questions/3423545/objective-c-iphone-percent-encode-a-string

上面的連結提供了一個不錯的方式處理

其他相關的知識

cocoa coding

http://secondflush2.blog.fc2.com/blog-entry-62.html

http://stackoverflow.com/questions/2467844/convert-utf-8-encoded-nsdata-to-nsstring

字串非 null-terminated

NSString* newStr = [[[NSString alloc] initWithData:theData

encoding:NSUTF8StringEncoding] autorelease];

null terminated 時,使用 stringWithUTF8String 避免結尾的 \0 產生多餘字元

If the data is null-terminated, you should instead use -stringWithUTF8String: to avoid the extra \0 at the end.

NSString* newStr = [NSString stringWithUTF8String:[theData bytes]];

NSString to ASCII 轉成 ASCII

NSString *string = @"2";

int asciiCode = [string characterAtIndex:0]; //50

base64-utf8编码的NSString转化为NSString

http://blog.csdn.net/chenghxc/article/details/8618580

1、NSData+Base64.h

[plain] view plaincopyprint?

  1. #import <Foundation/Foundation.h>  
  2.   
  3. void *NewBase64Decode(  
  4.     const char *inputBuffer,  
  5.     size_t length,  
  6.     size_t *outputLength);  
  7.   
  8. char *NewBase64Encode(  
  9.     const void *inputBuffer,  
  10.     size_t length,  
  11.     bool separateLines,  
  12.     size_t *outputLength);  
  13.   
  14. @interface NSData (Base64)  
  15.   
  16. + (NSData *)dataFromBase64String:(NSString *)aString;  
  17. - (NSString *)base64EncodedString;  
  18.   
  19. @end  

2、NSData+Base64.m

[plain] view plaincopyprint?

  1. #import "NSData+Base64.h"  
  2.   
  3. //  
  4. // Mapping from 6 bit pattern to ASCII character.  
  5. //  
  6. static unsigned char base64EncodeLookup[65] =  
  7.     "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";  
  8.   
  9. //  
  10. // Definition for "masked-out" areas of the base64DecodeLookup mapping  
  11. //  
  12. #define xx 65  
  13.   
  14. //  
  15. // Mapping from ASCII character to 6 bit pattern.  
  16. //  
  17. static unsigned char base64DecodeLookup[256] =  
  18. {  
  19.     xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx,   
  20.     xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx,   
  21.     xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, 62, xx, xx, xx, 63,   
  22.     52, 53, 54, 55, 56, 57, 58, 59, 60, 61, xx, xx, xx, xx, xx, xx,   
  23.     xx,  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14,   
  24.     15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, xx, xx, xx, xx, xx,   
  25.     xx, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,   
  26.     41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, xx, xx, xx, xx, xx,   
  27.     xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx,   
  28.     xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx,   
  29.     xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx,   
  30.     xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx,   
  31.     xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx,   
  32.     xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx,   
  33.     xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx,   
  34.     xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx,   
  35. };  
  36.   
  37. //  
  38. // Fundamental sizes of the binary and base64 encode/decode units in bytes  
  39. //  
  40. #define BINARY_UNIT_SIZE 3  
  41. #define BASE64_UNIT_SIZE 4  
  42.   
  43. //  
  44. // NewBase64Decode  
  45. //  
  46. // Decodes the base64 ASCII string in the inputBuffer to a newly malloced  
  47. // output buffer.  
  48. //  
  49. //  inputBuffer - the source ASCII string for the decode  
  50. //  length - the length of the string or -1 (to specify strlen should be used)  
  51. //  outputLength - if not-NULL, on output will contain the decoded length  
  52. //  
  53. // returns the decoded buffer. Must be free'd by caller. Length is given by  
  54. //  outputLength.  
  55. //  
  56. void *NewBase64Decode(  
  57.     const char *inputBuffer,  
  58.     size_t length,  
  59.     size_t *outputLength)  
  60. {  
  61.     if (length == -1)  
  62.     {  
  63.         length = strlen(inputBuffer);  
  64.     }  
  65.       
  66.     size_t outputBufferSize =  
  67.         ((length+BASE64_UNIT_SIZE-1) / BASE64_UNIT_SIZE) * BINARY_UNIT_SIZE;  
  68.     unsigned char *outputBuffer = (unsigned char *)malloc(outputBufferSize);  
  69.       
  70.     size_t i = 0;  
  71.     size_t j = 0;  
  72.     while (i < length)  
  73.     {  
  74.         //  
  75.         // Accumulate 4 valid characters (ignore everything else)  
  76.         //  
  77.         unsigned char accumulated[BASE64_UNIT_SIZE];  
  78.         size_t accumulateIndex = 0;  
  79.         while (i < length)  
  80.         {  
  81.             unsigned char decode = base64DecodeLookup[inputBuffer[i++]];  
  82.             if (decode != xx)  
  83.             {  
  84.                 accumulated[accumulateIndex] = decode;  
  85.                 accumulateIndex++;  
  86.                   
  87.                 if (accumulateIndex == BASE64_UNIT_SIZE)  
  88.                 {  
  89.                     break;  
  90.                 }  
  91.             }  
  92.         }  
  93.           
  94.         //  
  95.         // Store the 6 bits from each of the 4 characters as 3 bytes  
  96.         //  
  97.         // (Uses improved bounds checking suggested by Alexandre Colucci)  
  98.         //  
  99.         if(accumulateIndex >= 2)    
  100.             outputBuffer[j] = (accumulated[0] << 2) | (accumulated[1] >> 4);    
  101.         if(accumulateIndex >= 3)    
  102.             outputBuffer[j + 1] = (accumulated[1] << 4) | (accumulated[2] >> 2);    
  103.         if(accumulateIndex >= 4)    
  104.             outputBuffer[j + 2] = (accumulated[2] << 6) | accumulated[3];  
  105.         j += accumulateIndex - 1;  
  106.     }  
  107.       
  108.     if (outputLength)  
  109.     {  
  110.         *outputLength = j;  
  111.     }  
  112.     return outputBuffer;  
  113. }  
  114.   
  115. //  
  116. // NewBase64Encode  
  117. //  
  118. // Encodes the arbitrary data in the inputBuffer as base64 into a newly malloced  
  119. // output buffer.  
  120. //  
  121. //  inputBuffer - the source data for the encode  
  122. //  length - the length of the input in bytes  
  123. //  separateLines - if zero, no CR/LF characters will be added. Otherwise  
  124. //      a CR/LF pair will be added every 64 encoded chars.  
  125. //  outputLength - if not-NULL, on output will contain the encoded length  
  126. //      (not including terminating 0 char)  
  127. //  
  128. // returns the encoded buffer. Must be free'd by caller. Length is given by  
  129. //  outputLength.  
  130. //  
  131. char *NewBase64Encode(  
  132.     const void *buffer,  
  133.     size_t length,  
  134.     bool separateLines,  
  135.     size_t *outputLength)  
  136. {  
  137.     const unsigned char *inputBuffer = (const unsigned char *)buffer;  
  138.       
  139.     #define MAX_NUM_PADDING_CHARS 2  
  140.     #define OUTPUT_LINE_LENGTH 64  
  141.     #define INPUT_LINE_LENGTH ((OUTPUT_LINE_LENGTH / BASE64_UNIT_SIZE) * BINARY_UNIT_SIZE)  
  142.     #define CR_LF_SIZE 2  
  143.       
  144.     //  
  145.     // Byte accurate calculation of final buffer size  
  146.     //  
  147.     size_t outputBufferSize =  
  148.             ((length / BINARY_UNIT_SIZE)  
  149.                 + ((length % BINARY_UNIT_SIZE) ? 1 : 0))  
  150.                     * BASE64_UNIT_SIZE;  
  151.     if (separateLines)  
  152.     {  
  153.         outputBufferSize +=  
  154.             (outputBufferSize / OUTPUT_LINE_LENGTH) * CR_LF_SIZE;  
  155.     }  
  156.       
  157.     //  
  158.     // Include space for a terminating zero  
  159.     //  
  160.     outputBufferSize += 1;  
  161.   
  162.     //  
  163.     // Allocate the output buffer  
  164.     //  
  165.     char *outputBuffer = (char *)malloc(outputBufferSize);  
  166.     if (!outputBuffer)  
  167.     {  
  168.         return NULL;  
  169.     }  
  170.   
  171.     size_t i = 0;  
  172.     size_t j = 0;  
  173.     const size_t lineLength = separateLines ? INPUT_LINE_LENGTH : length;  
  174.     size_t lineEnd = lineLength;  
  175.       
  176.     while (true)  
  177.     {  
  178.         if (lineEnd > length)  
  179.         {  
  180.             lineEnd = length;  
  181.         }  
  182.   
  183.         for (; i + BINARY_UNIT_SIZE - 1 < lineEnd; i += BINARY_UNIT_SIZE)  
  184.         {  
  185.             //  
  186.             // Inner loop: turn 48 bytes into 64 base64 characters  
  187.             //  
  188.             outputBuffer[j++] = base64EncodeLookup[(inputBuffer[i] & 0xFC) >> 2];  
  189.             outputBuffer[j++] = base64EncodeLookup[((inputBuffer[i] & 0x03) << 4)  
  190.                 | ((inputBuffer[i + 1] & 0xF0) >> 4)];  
  191.             outputBuffer[j++] = base64EncodeLookup[((inputBuffer[i + 1] & 0x0F) << 2)  
  192.                 | ((inputBuffer[i + 2] & 0xC0) >> 6)];  
  193.             outputBuffer[j++] = base64EncodeLookup[inputBuffer[i + 2] & 0x3F];  
  194.         }  
  195.           
  196.         if (lineEnd == length)  
  197.         {  
  198.             break;  
  199.         }  
  200.           
  201.         //  
  202.         // Add the newline  
  203.         //  
  204.         outputBuffer[j++] = '\r';  
  205.         outputBuffer[j++] = '\n';  
  206.         lineEnd += lineLength;  
  207.     }  
  208.       
  209.     if (i + 1 < length)  
  210.     {  
  211.         //  
  212.         // Handle the single '=' case  
  213.         //  
  214.         outputBuffer[j++] = base64EncodeLookup[(inputBuffer[i] & 0xFC) >> 2];  
  215.         outputBuffer[j++] = base64EncodeLookup[((inputBuffer[i] & 0x03) << 4)  
  216.             | ((inputBuffer[i + 1] & 0xF0) >> 4)];  
  217.         outputBuffer[j++] = base64EncodeLookup[(inputBuffer[i + 1] & 0x0F) << 2];  
  218.         outputBuffer[j++] = '=';  
  219.     }  
  220.     else if (i < length)  
  221.     {  
  222.         //  
  223.         // Handle the double '=' case  
  224.         //  
  225.         outputBuffer[j++] = base64EncodeLookup[(inputBuffer[i] & 0xFC) >> 2];  
  226.         outputBuffer[j++] = base64EncodeLookup[(inputBuffer[i] & 0x03) << 4];  
  227.         outputBuffer[j++] = '=';  
  228.         outputBuffer[j++] = '=';  
  229.     }  
  230.     outputBuffer[j] = 0;  
  231.       
  232.     //  
  233.     // Set the output length and return the buffer  
  234.     //  
  235.     if (outputLength)  
  236.     {  
  237.         *outputLength = j;  
  238.     }  
  239.     return outputBuffer;  
  240. }  
  241.   
  242. @implementation NSData (Base64)  
  243.   
  244. //  
  245. // dataFromBase64String:  
  246. //  
  247. // Creates an NSData object containing the base64 decoded representation of  
  248. // the base64 string 'aString'  
  249. //  
  250. // Parameters:  
  251. //    aString - the base64 string to decode  
  252. //  
  253. // returns the autoreleased NSData representation of the base64 string  
  254. //  
  255. + (NSData *)dataFromBase64String:(NSString *)aString  
  256. {  
  257.     NSData *data = [aString dataUsingEncoding:NSASCIIStringEncoding];  
  258.     size_t outputLength;  
  259.     void *outputBuffer = NewBase64Decode([data bytes], [data length], &outputLength);  
  260.     NSData *result = [NSData dataWithBytes:outputBuffer length:outputLength];  
  261.     free(outputBuffer);  
  262.     return result;  
  263. }  
  264.   
  265. //  
  266. // base64EncodedString  
  267. //  
  268. // Creates an NSString object that contains the base 64 encoding of the  
  269. // receiver's data. Lines are broken at 64 characters long.  
  270. //  
  271. // returns an autoreleased NSString being the base 64 representation of the  
  272. //  receiver.  
  273. //  
  274. - (NSString *)base64EncodedString  
  275. {  
  276.     size_t outputLength;  
  277.     char *outputBuffer =  
  278.         NewBase64Encode([self bytes], [self length], true, &outputLength);  
  279.       
  280.     NSString *result =  
  281.         [[[NSString alloc]  
  282.             initWithBytes:outputBuffer  
  283.             length:outputLength  
  284.             encoding:NSASCIIStringEncoding]  
  285.         autorelease];  
  286.     free(outputBuffer);  
  287.     return result;  
  288. }  
  289.   
  290. @end  

3、NSString+Base64.h

[plain] view plaincopyprint?

  1. #import <Foundation/Foundation.h>  
  2.   
  3. @interface NSString (Base64)  
  4. + (NSString *)base64Encode:(NSString *)plainText;  
  5. + (NSString *)base64Decode:(NSString *)base64String;  
  6. @end  

4、NSString+Base64.m

[plain] view plaincopyprint?

  1. #import "NSString+Base64.h"  
  2. #import "NSData+Base64.h"  
  3. @implementation NSString (Base64)  
  4.   
  5. + (NSString *)base64Encode:(NSString *)plainText  
  6. {  
  7.     NSData *plainTextData = [plainText dataUsingEncoding:NSUTF8StringEncoding];  
  8.     NSString *base64String = [plainTextData base64EncodedString];  
  9.     return base64String;  
  10. }  
  11.   
  12. + (NSString *)base64Decode:(NSString *)base64String  
  13. {  
  14.     NSData *plainTextData = [NSData dataFromBase64String:base64String];  
  15.     NSString *plainText = [[NSString alloc] initWithData:plainTextData encoding:NSUTF8StringEncoding];  
  16.     return plainText;  
  17. }  
  18. @end  

5、实例代码:

[plain] view plaincopyprint?

  1. #import "AppDelegate.h"  
  2. #import "NSString+Base64.h"  
  3.   
  4. @implementation AppDelegate  
  5.   
  6. @synthesize window = _window;  
  7.   
  8. - (void)dealloc  
  9. {  
  10.     [super dealloc];  
  11. }  
  12.       
  13. - (void)applicationDidFinishLaunching:(NSNotification *)aNotification  
  14. {  
  15.     NSString *str = @"未加密字符串";  
  16.     NSLog(@"nsstring: %@",str);  
  17.     NSString *base64utf8 = [NSString base64Encode:str];  
  18.     NSLog(@"base64utf8: %@",base64utf8);  
  19.     NSLog(@"nsstring: %@",[NSString base64Decode:base64utf8]);  
  20. }  
  21.   
  22. @end  

2013年5月10日 星期五

MAC 使用 intellij 開發 Grails 環境配置

  1. 安裝 homebrew

        使用 brew install grails 安裝最新版 grails

        需要其他版本的話

http://blog.jdriven.com/2012/09/quick-tip-installing-a-specific-grails-version-on-os-x-using-homebrew/

        使用 brew version grails 取得版本

        使用以下指令和版本的 hash coe 安裝不同版本

cd `brew --prefix`                              

git checkout 624e065 Library/Formula/grails.rb   # use output of "brew versions"

brew install grails                              # install grails

git checkout -- Library/Formula/grails.rb        # reset formula

        然後使用 brew switch grails version 切換版本

        如果新建/匯入專案時,IDEA 要求提供 Grails SDK 的話

        /usr/local/Cellar/grails/<version>/libexec

        純手工搭建方法

        http://thewidgetsmith.com/2013/01/grails-development-environment-set-up-os-x/

2013年5月9日 星期四

Mobile analytics 小測試

GAI - Goole Analytics

有提供即時的資訊

不過即時資訊提供的資訊不多

統計資訊大概要等各4小時才可用

功能..算是最複雜的吧

不過也可能是 UI 的不友善導致..

Flurry

整合的不錯,跟 GAI 有得拼

資訊統計時間有點久

初次使用時,三個小時後依然沒有看到資訊

明明手冊上面說只要一個小時..

慢到我都回頭去看看是否有缺少什麼設定..

看完之後還是沒資料 orz

只好隔天再來補完這段

修正:其實速度不錯,我昨天看錯圖表了

Localytics

iOS API 的方便性不是很好

需要自己在 Application Events 中加入 resume/stop/upload 方法

資料顯示的蠻快的

畫面風格很長簡潔,收費項目也很俐落的穿插在各個功能之中..

如果只是想看比較簡單的使用行為,算是蠻方便的

至於比較複雜的行為分析與追蹤,要等之後資料量變大後,再來開啟 premium 功能測試

不過 Localytics 竟然連 screen 都算在 premium 功能中…這真是令人噁心

MixPanel

SDK 便利性算是最差了(雖然也沒差到哪邊)

和 Localytics 算是互有勝場,不過都比不上 FLurry 方便

資料非常即時

不過感覺上用來追蹤(少數)使用者行為比較方便

但是會有這感覺和按鈕字體很大,不太好挑資料有點關係 :p

此外,介紹影片很多也很用心

目前 2013年5月9日 的 Mixpanel 已經跟 2010 年介紹的差異很大了

http://www.inside.com.tw/2010/11/09/mixpanel-realtime-analytics-for-web-and-mobile-applications

2013年5月8日 星期三

Inhouse app installs failed after provisioning updated

in-house app 在 provisioning profile 更新後,馬上就陷入無法安裝情況

以下是 console log

iOS ipa 結構

全新製作的流程

http://itools.hk/article59.htm

對 ipa 有興趣的話,可以看這邊的資源

http://blog.csdn.net/chengyakun11/article/details/8497733

iOS 使用的安裝格式

http://www.helmsmansoft.com/index.php/archives/1824

ipa 結構

http://floatlearning.com/2011/11/re-signing-an-ios-app-without-xcode/

文章介紹了 ipa 的檔案結構

iTunesArtwork

iTunesMetadata

Payload - App Binary //檔案

         - Bundle resources //資源

         - embedded.mobileprovision // provisioning 檔案

         - _CodeSignature // code sign

一般來說,dev app 並不需要 entitlement 檔案

除非有需要使用到需由 entitlement 指定的 push/iCloud 或類似服務

re-signing app

如果想要更新 app 的 provisioning

可以使用 /use/bun/codesign 處理

這樣的機會也許不會太多

不過當app 只有 mobile provisioning 改變的情況下

也許會希望使用這種作法

(新增裝置時,加入裝置的 UDID 後,需要更新 provision 檔案並重新簽署

重新簽署動作的 script

https://gist.github.com/mediabounds/1367348

AppResigner

http://www.gorbster.net/blog/archives/273

重新簽署 app 的 app (只認 .app 檔案,不認 .ipa)

Apple Developer Program 新版頁面 2013年5月8日

前陣子剛寫過一篇

沒想到這麼快就改版了

沒想到這麼快就看不懂了..

沒想到這麼快就要重寫一次了 orz

ADP overview 頁面

PastedGraphic-2013-05-8-10-40.png

Certificates 頁面

這次 Apple 把 APNS certificates 分出來了

PastedGraphic1-2013-05-8-10-40.png

一個帳號應該只會有一個的 dev certificates

PastedGraphic2-2013-05-8-10-40.png

Production certificates 頁面

APNS

PastedGraphic3-2013-05-8-10-40.png

同樣,應該只會有一個的 production certificates

PastedGraphic4-2013-05-8-10-40.png

App ID 頁面

PastedGraphic5-2013-05-8-10-40.png

Devices 頁面

PastedGraphic6-2013-05-8-10-40.png

Dev Provisioning 頁面

PastedGraphic8-2013-05-8-10-40.png

Prod Provisioning 頁面

PastedGraphic10-2013-05-8-10-40.png

整體來說

這次改版後,資料的預覽程度有增加,不用點進去就可以看到詳細資訊

不過流程有點混亂..

最後G一下

Apple 不知道在搞什麼鬼

前兩天(5/6)建立新的 app id 和相關設定(push)後

竟然出現了之前刪除的 certificates,導致我擁有三個同名的 dev vert,兩個 prod certificates

然後 Xcode 就風中殘燭不知如何編譯..

刪除重複檔案後,雖然把所有的 prov 都使用新的 cert 簽署

而理論上之前已經簽署的檔案也不該有問題

但是之前用 PhoneGap 封裝的 ipa 還是出現無法安裝問題…

2013年5月7日 星期二

取得出現頻率最高資料

mark 一下,晚點看

來源 http://d.hatena.ne.jp/tanaponchikidun/searchdiary?word=%2A%5Bobjective-c%5D

// NSNumber配列を初期化

NSArray *numbers = @[@9,@4,@5,@1,@1,@17,@9,@6,@9];

// 昇順ソート

NSArray *asecNumbers = [numbers sortedArrayUsingSelector:@selector(compare:)];

NSLog(@"asecNumbers = %@",asecNumbers);

// 降順ソート

NSSortDescriptor *descDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"self" ascending:NO];

NSArray *descNumbers = [numbers sortedArrayUsingDescriptors:@[descDescriptor]];

NSLog(@"descNumbers = %@",descNumbers);

// 最大、最小、平均、合計値の取得

NSLog(@"max of numbers = %@",[numbers valueForKeyPath:@"@max.self"]);

NSLog(@"min of numbers = %@",[numbers valueForKeyPath:@"@min.self"]);

NSLog(@"avg of numbers = %@",[numbers valueForKeyPath:@"@avg.self"]);

NSLog(@"sum of numbers = %@",[numbers valueForKeyPath:@"@sum.self"]);

// 重複データを取り除く

NSArray *distinctNumbers = [numbers valueForKeyPath:@"@distinctUnionOfObjects.self"];

NSLog(@"distinctNumbers = %@",distinctNumbers);

// 6以上のデータを取得

NSPredicate *over6Pred = [NSPredicate predicateWithFormat:@"SELF >= 6"];

NSArray *over6Array = [numbers filteredArrayUsingPredicate:over6Pred];

NSLog(@"over6Array = %@",over6Array);

// 最頻出のデータを取得

NSCountedSet *set = [NSCountedSet setWithArray:numbers];

int highest = 0;

NSNumber *mostFqtNumber = @0;

for (NSNumber *n in set) {

if ([set countForObject:n] > highest) {

highest = [set countForObject:n];

mostFqtNumber = n;

}

}

NSLog(@"most frequent number = %@",mostFqtNumber);