问题标签 [nsscanner]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
734 浏览

iphone - Problem with NSScanner! Get url of img tags!

I use this code to retrive the first image of a feed... the htmlString contains html tags and in same cases I can get correctly the first image but in other cases i get a nil NSString. I don't understand why. I'm sure that the htmlString contains one image. For example for this String I can't get correctly the first image.

Example: CultOfMac ha segnalato la disponibilità sul Mac App Store delle prime applicazioni sviluppate appositamente per OS X 10.7 Lion. In passato situazioni come questa hanno preceduto di qualche ora il lancio di nuovi prodotti, basti pensare al rilascio di iOS 4.2.1 per iPhone e iPad, primo firmware che ha unificato la numerazione delle versioni di sistema di questi dispositivi. OS X Lion è più vicino al rilascio?</p> <p><img class="aligncenter size-full wp-image-21789" title="mac-app-store_t" src="http://static.slidetomac.com/wp-content/uploads/2011/07/mac-app-store_t.jpg" alt="" width="507" height="300" /></p> <p><span id="more-21780"></span></p> <p>Solo qualche giorno fa Apple....

The part of code that I need is: <img class="aligncenter size-full wp-image-21789" title="mac-app-store_t" src="http://static.slidetomac.com/wp-content/uploads/2011/07/mac-app-store_t.jpg" alt="" width="507" height="300" /

But I can't get correctly the url of the image... What's wrong in my code? thanks

0 投票
2 回答
904 浏览

objective-c - NSTextView enclosing scroll view jumps on spacebar

I have an odd behavior with my app and I don't know where it comes from. I have implemented a NSScanner for a text view content that works very well. The scanner works in conjunction with the text storage to set attributes on the text storage string via text view delegate methods. However, each time I enter a space, the enclosing scroll view scrolls back to the top of the text view. Can anyone give me a hint where this comes from ?

0 投票
1 回答
1258 浏览

cocoa - 使用 NSScanner 解析字符串

要解析的两行字符串是:

取出这些字符串:

(从第一行开始)

  • VGA兼容控制器
  • Intel Corporation 82945G/GZ 集成图形控制器
  • [8086:2772]

(从第 2 行开始)

  • 显示控制器
  • Intel Corporation 82945G/GZ 集成图形控制器
  • [8086:2776]

现在我的起始代码是:

这不起作用。我什至无法理解文档中的扫描仪。那么有人可以发布工作代码吗?

0 投票
3 回答
617 浏览

iphone - 从给定的字符串中查找带有数字的字符。

如何使用 NSScanner 从包含字符串和数字的字符串中获取字符串?

即001234852ACDSB

结果应该是 001234852 和 ACDSB

我可以使用 NSScanner 从字符串中获取数字,并通过使用stringByReplacingOccurrencesOfString从字符中获取数字,但我想知道,是否可以使用 NSScanner 或任何其他内置方法获取字符串?

我想知道同样的正则表达式。

0 投票
2 回答
36094 浏览

arrays - 将字符串拆分为数组的最佳方法

我正在开发一个旅行应用程序,我必须阅读一个包含所有州和国家/地区的 txt 文件,因为您会注意到这是一个非常大的文件,无论如何,这是文件中的文本示例:

Zakinthos (ZTH),希腊
Zanesville (ZZV),美国
Zanjan (JWN),伊朗
Zanzibar (ZNZ),TANZANIA
...

现在我正在毫无问题地读取文件,但我不知道如何创建两个数组,一个与州有关,另一个与国家/地区有关,因此我可以在自动完成文本时将它们显示到表格中。

我尝试使用 NSScanner 使用“,”作为分隔符,但我不知道如何使它起作用,而且我尝试使用 NSString 方法但没有结果。

欢迎任何帮助,在此先感谢您!!!!

顺便说一句,对不起我的英语 XD

0 投票
1 回答
263 浏览

iphone - iphone nscanner 问题

当它扫描动态输入的字符串时,nsscanner 似乎无法完成她的工作。让我先写我的代码:

我已经在许多方法中尝试了这些代码,但我得到了相同的结果:当我在搜索栏中写一些东西时,模拟器在没有任何崩溃日志的情况下自行终止。mySearchBar 以编程方式添加,属于 UISearchBar 类,并链接到 self.

当我尝试在 filterContent 方法中将 settext 重写为 searchText 以进行搜索和比较时,NSLog 显示了无穷无尽的数量

  • “扫描:MainViewController”

或者

  • “扫描:(我输入的第一个字符)”

然后坠毁。MainViewController 属于 UIViewController 类。

我已经尝试过 Apple 文档中的这些代码;

http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Strings/Articles/Scanners.html

它可以在任何方法中完美运行。这段代码的 NSLog 出现过一次,并且写得很完美。但我不明白为什么这段代码有效,而不是我的。

我的目标是检测搜索栏中的特殊字符。如果搜索栏中的文本包含这样的字符,那么我可以禁用NSDiactricInsensitiveSearch. NSComparisonResult然后搜索结果将显示包含特殊字符的单词,这些字符不是变音字符的一部分。


编辑 8 月 16 日:

好的,这是我的 nscomparisonresult 代码。@JohnBrighton:`s 解决方案有效,但 nslog 进入了 for 循环,我无法在应用程序上单击我输入的第一个字符的任何内容...如果我在 for 循环之前粘贴这些代码,则搜索不起作用;


编辑 8 月 17 日,重写了上面的代码,所以整个方法是可见的:

它提出了无数的 NSLogs 显示“所用时间:0”而不是“所用时间:0.0000”来自您之前的代码。

0 投票
5 回答
11768 浏览

iphone - 是什么导致“NSScanner:零字符串参数”?

将数据保存到核心数据时收到此消息。

我没有使用任何 NSScanner 方法。它从哪里来的?

这是一个错误?我该怎么办?

谢谢帮忙,拜托。

0 投票
2 回答
231 浏览

iphone - 如何将 NSScanner 值转换为字符串?

大家好,你能告诉我如何从字符串中获取 NSScanner 的值吗?感染我必须从字符串中提取 int 值,我正在使用扫描仪提取它,现在我的值在扫描仪中。现在如何获得该值?

现在我的价值在哪里以及如何使用?

0 投票
1 回答
1307 浏览

ios - 从xml字符串objective-c获取子字符串

我知道这个问题已经被问过很多次了。我有包含 xml 的响应字符串。

对于每个请求,我都会收到新的短 xml 字符串,并且我需要在“响应”节点中获取值。我怎么能做到这一点,而不创建 xml 解析器?我不想为这个短 xml 创建 xml 解析器。

0 投票
1 回答
395 浏览

objective-c - scanCharactersFromSet:intoString: 创建一个自动释放的字符串吗?

在使用 Instruments 时,这种方法似乎存在泄漏 ( scanCharactersFromSet:intoString:)。我没有释放放入的变量intoString

此方法是否在方法的一部分中创建保留或自动释放的字符串intoString