Error "Missing '[' at start of message send Expression"

Asked

Viewed 35 times

0

Good evening everyone, I’m doing the integration of Moip’s SDK(a payment gateway) but my knowledge is more in Swift(which I started a few months ago).

They provide the sdk for encryption of sensitive credit card data, but I’m getting a seemingly simple error but I don’t know how to fix it, as if a bracket is missing from the code line.

#import "MoipCrypt.h"
#import <MoipSDK/MoipSDK.h>

@implementation MoipCrypt

NSString *myPublicKey = @"-----BEGIN PUBLIC KEY-----CHAVE PUBLICA-----END PUBLIC KEY-----";
[MoipSDK importPublicKey:myPublicKey];

@end

The error is on the line

[MoipSDK importPublicKey:myPublicKey];

Where the following messages appear:

Expected ']' Expected Identifier or '(' Missing '[' at start of message send Expression

Even the solution given by Xcode ("Insert ';'") only causes other syntax errors.

The sdk github link is as follows:

Moip Encryption sdk-Ios

Thank you all for your help.

1 answer

0

This is because you are not declaring it within a method, so it is only as dropped code within a file

try like this:


#import "MoipCrypt.h"
#import 

@implementation MoipCrypt

-(void) anyFunction{

    NSString *myPublicKey = @"-----BEGIN PUBLIC KEY-----CHAVE PUBLICA-----END PUBLIC KEY-----";
    [MoipSDK importPublicKey:myPublicKey];
}

@end

Browser other questions tagged

You are not signed in. Login or sign up in order to post.