DjamilBahirov
DjamilBahirov

Reputation: 35

Why I get error for string variable?

I have the declared variable:

@property(strong, nonatomic) NSString* like_id;

I call function GetLike inside - (void)viewDidLoad {}

- (void) GetLike {
   if(![self.like_id isEqualToString:@""]){
     // TODO
   }
}

I get error: Thread 1, signal SIGABRT

Upvotes: 0

Views: 72

Answers (1)

Hima
Hima

Reputation: 1247

This works fine for me.

@interface ViewController ()
@property(strong, nonatomic) NSString* like_id;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self getLike];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

- (void)getLike {
    if(![self.like_id isEqualToString:@""]){
        NSLog(@"Liked !");
    }
}
@end

Upvotes: 2

Related Questions