0

It seems like I have the correct code, and it compiles, runs, and builds. BUT it does not carry out certain lines of code because of the following error: "NSString may not respond to EncryptAES"

The code where the warning occurs is contained below:

- (IBAction)Encrypt {
//Change the Input String to Data
NSData *objNSData = [NSData dataWithData:[Input dataUsingEncoding: NSUTF8StringEncoding]];
//Encrypt the Data    
objNSData = [Input EncryptAES:Keyword.text]; //Line with Warning

I have searched StackOverflow for problems like this and figured that to cure this error I should use some sort of code like this in my header file:

@interface  NSString

-(NSString*)AESEncrypt:????

@end

Would this fix the warning? If so, then what do I put where the questions go? If this code will not fix the problem then what do I do to get rid of this error and make the code function?

EDIT: I have also tried this using NSData, I get the same resulting warning

Sam Spencer
  • 8,492
  • 12
  • 76
  • 133

2 Answers2

2

You're calling EncryptAES class method against "Input" which based on your comment and code above ([Input dataUsingEncoding...) appears to be an NSString.

NSString does not offer an EncryptAES method:

http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/Reference/NSString.html

Checkout these SO posts:

AES Encryption for an NSString on the iPhone

uses: http://pastie.org/426530

iPhone - AES256 Encryption Using Built In Library

Community
  • 1
  • 1
bryanmac
  • 38,941
  • 11
  • 91
  • 99
0

See here. Apparently EncryptAES is a "category" for NSData. I doubt that it will work on an NSString.

Community
  • 1
  • 1
Hot Licks
  • 47,103
  • 17
  • 93
  • 151