Breaking News
Home / iOS / ObjectiveC / How to check if a String begin with an character in Objective C?

How to check if a String begin with an character in Objective C?

Answer

Use the hasPrefix message for the string object.

NSString *input = @”*welcome”;

NSString *output = nil;

if([input hasPrefix:@”*”])
    output = [input substringFromIndex:1] [pb_builder]

Check Also

Singleton Example in Objective C?

Solution static MyManager *sharedManager = nil; +(MyManager*) sharedManager {         if (sharedManager == nil)         …

Advertisment ad adsense adlogger