Sam Spencer
Sam Spencer

Reputation: 8609

NSString may not respond to EncryptAES- Xcode Warning

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

Upvotes: 0

Views: 369

Answers (2)

bryanmac
bryanmac

Reputation: 39296

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

Upvotes: 2

Hot Licks
Hot Licks

Reputation: 47729

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

Upvotes: 0

Related Questions