zoukankan      html  css  js  c++  java
  • How to check if NSString begins with a certain character

    How to check if NSString begins with a certain character

    How do you check if an NSString begins with a certain character (the character *).

    The * is an indicator for the type of the cell, so I need the contents of this NSString without the *, but need to know if the * exists.

    You can use the -hasPrefix: method of NSString:

    NSString* output = nil;
    if([string hasPrefix:@"*"])
        output = [string substringFromIndex:1];
  • 相关阅读:
    个人博客
    个人博客
    5.4
    4.30
    4.29
    4.28
    4.27
    4.26
    4.25
    4.24
  • 原文地址:https://www.cnblogs.com/savagemorgan/p/3842672.html
Copyright © 2011-2022 走看看