2013-10-22 84 views
1

I use a AES library from github NSData+AES by nicerobot's objcNSData的AES觸發無法識別的選擇發送到實例錯誤

我的代碼如下所示:

- AESLib.h -

#import <Foundation/Foundation.h> 
#import <CommonCrypto/CommonCrypto.h> 

@interface AESLib : NSObject 
-(NSData *) encodeAES:(NSData *) argSource; 
@end 

- AESLib.m -

-(NSData *) encodeAES:(NSData *) argSource 
{ 
    NSString APIV1_AES_KEY = @"//AAAAAAAAAAAAAAAAAAAAAA"; // 24 char 
    NSString APIV1_AES_IV = @"//BBBBBBBBBBBBBB"; // 16 char 
    NSData *key = [NSData dataWithBytes:APIV1_AES_KEY.UTF8String length:strlen(APIV1_AES_KEY.UTF8String)]; 
    NSData *iv = [NSData dataWithBytes:APIV1_AES_IV.UTF8String length:strlen(APIV1_AES_IV.UTF8String)]; 

    NSData *encData; 
    @try { 
     encData = [argSource encrypt:key withInitial:iv andPadding:kCCOptionPKCS7Padding]; 
     // Error Here 
     return encData; 
    } 
    @catch (NSException *exception) { 
     NSLog(@"Exception : %@", [exception reason]); 
    } 

    return nil; 
} 

//錯誤

> XCode trigger error 2013-10-22 16:15:58.206 Aessample[2913:c07] 
> -[NSConcreteMutableData encrypt:withInitial:andPadding:]: unrecognized selector sent to instance 0x7523300 2013-10-22 16:15:58.207 
> Aessample[2913:c07] Exception : -[NSConcreteMutableData 
> encrypt:withInitial:andPadding:]: unrecognized selector sent to 
> instance 0x7523300 

爲什麼會發生此錯誤?

---加入的NSMutableString

謝謝你的NSMutableString。

我做過再次嘗試同樣你的答案,但我的代碼觸發仍然相同的錯誤。

再次幫助NSMutableString plz。

+0

你在'AESLib.m'中執行'#import '?自從我幾年前發佈該代碼以來,我一直沒有觸及該代碼。我會盡量花時間用最新的工具進行測試。 – nicerobot

回答

相關問題