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];

How to check if NSString begins with a certain character,布布扣,bubuko.com

时间: 2024-10-22 21:13:28

How to check if NSString begins with a certain character的相关文章

An Implementation of Double-Array Trie

Contents What is Trie? What Does It Take to Implement a Trie? Tripple-Array Trie Double-Array Trie Suffix Compression Key Insertion Key Deletion Double-Array Pool Allocation An Implementation Download Other Implementations References What is Trie? Tr

iOS数据存储的几种方式

iOS的数据存储是iOS应用开发的重要知识点: 关于这方面知识,网上有很多介绍,但对于代码层次的使用方式并未有系统全面介绍.此文章针对iOS稍熟悉的童鞋,需要对CoreData的原理有一定的了解.目前存储方式大概有以下几种: NSKeyedArchiver  适用简单数据加密 NSUserDefaults  适用配置参数 Write  文件操作,同NSKeyedArchiver SQLite3  操作较复杂,不建议使用. CoreData  取代SQLite3,但要遵循NSManagedObje

双数组Trie的一种实现

An Implementation of Double-Array Trie 双数组Trie的一种实现 原文:http://linux.thai.net/~thep/datrie/datrie.html 引文:http://quweiprotoss.blog.163.com/blog/static/4088288320091120112155178/ Contents What is Trie? What Does It Take to Implement a Trie? Tripple-Arr

java.lang.Long 类源码解读

总体阅读了Long的源码,基本跟Integer类类似,所以特别全部贴出源码,直接注释进行理解. 1 // final修饰符 2 public final class Long extends Number implements Comparable<Long> { 3 /** 4 * A constant holding the minimum value a {@code long} can 5 * have, -2<sup>63</sup>. 6 */ 7 // 最

Remove duplicates

https://github.com/Premiumlab/Python-for-Algorithms--Data-Structures--and-Interviews/blob/master/Mock%20Interviews/Social%20Network%20Company/Social%20Network%20Company%20-%20Interview%20Questions%20-%20SOLUTIONS/Phone%20Screen%20-%20SOLUTION.ipynb P

立即执行函数(IIFE)的理解与运用

作为JavaScript的常用语法,立即执行函数IIFE(Immediately-Invoked Function Expression)是值得我们认真去学习探究的. 一.创建函数的两种方式 我们先从基础讲起,要创建一个JS函数,有两种方式. (一)函数定义(Function Declaration) function Identifier ( Parameters ){ FunctionBody } 函数定义中,参数(Parameters)标识符(Identifier )是必不可少的.如果遗漏

第17章 标准库特殊设施

17.1类型tuple tuple是类是pair的模板.每个pair都不相同,但是都有两个成员.而一个tuple类型会有任意数量的成员.(定义在tuple头文件中) tuple<T1,T2,...,Tn> t; t是一个tuple,成员数位n,第i个成员的类型为Ti.所有成员都进行值初始化 tuple<T1,T2,...,Tn> t(v1,v2,...,vn); t是一个tuple,成员类型为T1,T2,...,Tn,每个成员用对应的初始值vi进行初始化.此构造函数是explici

String对象的方法

Function Description Example CompareTo() Compares one string to another ("Hello").CompareTo("Hello") Contains() Returns "True" if a specified comparison string is in a string or if the comparison string is empty ("Hello&

jQuery1.4源码解读

/*! * jQuery JavaScript Library v1.4 * http://jquery.com/ * * Copyright 2010, John Resig * Dual licensed under the MIT or GPL Version 2 licenses. * http://docs.jquery.com/License * * Includes Sizzle.js * http://sizzlejs.com/ * Copyright 2010, The Doj