Tag: string

不区分大小写的stringsearch – iphone

我正在寻找一种方法来在Objective-C中的另一个string中执行不区分大小写的stringsearch。 我可以find方法来search区分大小写的string,并比较不敏感的情况下,而不是search+不区分大小写。 我想要执行的search示例: “约翰”在“我告诉约翰find我一个好的searchalgorithm” 在“我认为这是一个真正的想法发表这个问题”的“糟糕的IDEA” 我宁愿只坚持NSStrings。

将parameter passing给select器动作

我正处于一种我认为自己接近解决的情况,但也许不是。 我有一个自定义tableview单元格的tableview。 目前每个tableviewcell有3个uibuttons,访问它们并赋予它们function是没有问题的。 我遇到问题的3个button之一。 该button将用户从当前的导航控制器推到一个webview控制器,但我希望webview控制器是当前tableview单元格持有的http地址。 下面是我正在使用的代码的一小部分。 – (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *cellIdentifier = @"Identifier"; SearchTableCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier]; if (cell == nil) { NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"SearchTableCell" owner:nil options:nil]; //cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:reuseIdentifier]; for(id currentObject in topLevelObjects) { if([currentObject isKindOfClass:[SearchTableCell class]]) { cell = (SearchTableCell *)currentObject; […]

有一个格式说明符与布尔值一起工作吗?

我想要做这样的事情: NSLog(@"You got: %x", booleanValue); 其中x是说明符。 但我找不到一个! 我想避免: if (booleanValue) { NSLog(@"You got: YES"); } else { NSLog(@"You got: NO"); } 有任何想法吗? 文档没有布尔说明符。 %@也没有工作。

用NSNumberFormatter防止小数

我有一个NSNumberFormatter,我试图用来从一个NSNumber生成一个GBP(£)的整数。 无论我尝试哪种咒语,我都会得到两位小数。 我的代码是: NSNumberFormatter *fmtCurrency = [[[NSNumberFormatter alloc] init] autorelease]; [fmtCurrency setNumberStyle: NSNumberFormatterCurrencyStyle]; [fmtCurrency setGeneratesDecimalNumbers:FALSE]; [fmtCurrency setCurrencyCode:@"GBP"]; [fmtCurrency setCurrencySymbol:@"£"]; txtTotal.text = [fmtCurrency stringFromNumber: result.Bill ]; // this is an NSNumber

将NSInteger转换为NSString

我正在尝试从几个不同的部分中创build一个string。 这下面是我现在所拥有的。 我没有在我的代码中有任何错误,但只要我运行这个,做触发它的事件,我得到EXC_BAD_ACCESS 。 有没有另一种方法将此NSInteger转换为NSString ? NSString *part1, *part2, *tempString; NSInteger num1; NSInteger num2; part1=@"some"; part2=@"text"; tempString = [NSString stringWithFormat:@"%@%@%@%@", part1, (NSString *)num1, part2, (NSString *)num2];

IOS:NSString从string中检索一个子string

嘿,我正在寻找一种方法来从另一个string中提取string。 它可以是任何长度,并在string的任何部分,所以通常的方法不起作用。 例如http://bla.com/bla?id=%1234%&something=%888% 我想提取的是从id =%到下一个%。 有任何想法吗?

来自NSString的子string

我正在使用NSString ,我想获得包含我的string的前20个字符的子string。 我怎样才能做到这一点?

在string中连接stringObjective-c

我想在一个string中放置一个string。 基本上是伪代码: "first part of string" + "(varying string)" + "third part of string" 我怎样才能在objective-c中做到这一点? 有没有办法在obj-c中轻松地连接? 谢谢!

不能用stringreplacestring

我有UITableViewCell与detailTextLabel其中包含string,我想用空间replace(换句话说,删除)。它看起来像这样: cell.detailTextLabel?.text = newsModel.pubDate 现在,问题是,当我写cell.detailTextLabel?.text?.stringByReplacingOccurrencesOfString("+0000", withString: " ") 它不工作,编译器说: “调用结果”stringByReplacingOccurrencesOfString(_:withString:options:range :)'未使用“ 任何人都可以告诉我解决scheme? 谢谢

为什么是可选的(“文本”) – 斯威夫特

我刚开始使用Swift。 所以我创build了一个带有标签,button和文本字段的简单应用程序。 当您点击button时,应用程序必须使用文本字段的文本更改标签。 class ViewController: UIViewController { @IBOutlet weak var textLabel: UILabel! @IBOutlet weak var textField: UITextField! @IBAction func updateButton(sender: UIButton) { textLabel.text = "Hi \(textField.text) " } 结果是 嗨可选(“TextOfTextField”) 好的。 所以这是一个非常简单的问题。 我希望有一个人可以帮助我。