将转义的UTF8字符转换回原来的forms

我试图从一个数组中读取来自plist的string并打印这些string。 数组中的string包含转义的UTF8字符 – 例如,当从plist中读取时,“NušaFlorjančič”变成"Nu\u0161a Florjan\u010di\u010d" 。 没有办法改变plist的内容,但我的程序需要正确显示名称。 奇怪的是Objective-C似乎在我对string进行硬编码时会自动执行此操作。 但是,如果我从plist得到的string什么都没有发生。 举个例子,下面是一些代码: NSString *name1 = @"Nu\u0161a Florjan\u010di\u010d"; NSString *name2 = [list objectAtIndex:0]; NSLog(@"name 1: %@", name1); NSLog(@"name 2: %@", name2); [list objectAtIndex:0]包含@"Nu\u0161a Florjan\u010di\u010d" – 唯一的区别是它已经通过plist编辑器设置。 控制台输出是: 2011-10-22 18:00:02.595 Test[13410:11c03] name 1: Nuša Florjančič 2011-10-22 18:00:02.595 Test[13410:11c03] name 2: Nu\u0161a Florjan\u010di\u010d 我尝试了各种各样的东西,包括将string转换为Cstring,然后创build一个UTF-8编码的NSString对象,但没有任何工作。 我真的很感谢你的指点,可以帮助我解决这个看似平淡的问题。

如何在iphone中获得蓝牙(开/关)的状态

我试图以编程方式获取iPhone / iPod蓝牙的状态,无论它是打开还是closures。 是否有可能使用一些苹果API或第三方API。

如何animationUILabel的背景颜色?

这看起来应该工作,但不是。 颜色立即变成绿色。 self.labelCorrection.backgroundColor = [UIColor whiteColor]; [UIView animateWithDuration:2.0 animations:^{ self.labelCorrection.backgroundColor = [UIColor greenColor]; }];

如何在iOS App中支持Universal Links并为其设置服务器?

如何在我的iOS应用程序中支持通用链接并设置我的服务器以支持通用链接?

迅速不同的图像注释

我设法在Swift中获得了一个注释引脚的自定义图标,但是现在我仍然使用2个不同的图像来注释不同的注释。 现在一个button添加一个注释到地图。 应该有另一个button,也添加注释,但与另一个图标。 有没有办法使用这个重用ID? class ViewController: UIViewController, MKMapViewDelegate { @IBOutlet weak var Map: MKMapView! @IBAction func btpressed(sender: AnyObject) { var lat:CLLocationDegrees = 40.748708 var long:CLLocationDegrees = -73.985643 var latDelta:CLLocationDegrees = 0.01 var longDelta:CLLocationDegrees = 0.01 var span:MKCoordinateSpan = MKCoordinateSpanMake(latDelta, longDelta) var location:CLLocationCoordinate2D = CLLocationCoordinate2DMake(lat, long) var region:MKCoordinateRegion = MKCoordinateRegionMake(location, span) Map.setRegion(region, animated: true) var information […]

如何正确使用“openParentApplication”和“handleWatchKitExtensionRequest”以便“reply()”被调用?

情况:我在Watch应用程序中使用openParentApplication在主应用程序中调用handleWatchKitExtensionRequest 。 这在模拟器中很好地工作,它也适用于实际的设备(苹果手表和iPhone),当iPhone应用程序是主动/打开。 问题:当我在实际设备(Apple Watch和iPhone)上运行它时,当主iPhone应用程序未处于活动状态或打开状态时, handleWatchKitExtensionRequest不会将数据返回到openParentApplication 。 WatchKit扩展中的InterfaceController.m中的代码: NSDictionary *requst = @{ @"request" : @"getData" }; [InterfaceController openParentApplication:requst reply:^( NSDictionary *replyInfo, NSError *error ) { // do something with the returned info }]; iPhone上的主应用程序的代理代码: – (void)application:(UIApplication *)application handleWatchKitExtensionRequest:(NSDictionary *)userInfo reply:(void ( ^)( NSDictionary * ))reply { if ( [[userInfo objectForKey:@"request"] isEqualToString:@"getData"] ) { // get […]

在swift中parsinghtml的最佳实践是什么?

我是一个Swift新手。 我需要在Swift iOS项目中使用Python的BeautifulSoup。 准确地说,我需要获得以".txt"结尾的<a>所有href 。 我应该采取什么措施?

如何使应用程序完全正确工作在iOS 6自动旋转?

在iOS6中,不推荐使用shouldAutorotateToInterfaceOrientation。 我试图使用supportedInterfaceOrientations和shouldAutorotate使应用程序正常自动旋转,但失败。 这个ViewController我不想旋转,但它不工作。 – (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return (interfaceOrientation == UIInterfaceOrientationPortrait); } -(BOOL)shouldAutorotate { return NO; } -(NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskPortrait; } 有任何想法吗? 提前感谢您的帮助!

从资源加载JavaScript到UIWebView

我需要从我的应用程序资源文件夹加载JavaScript文件。 截至目前,它确实从资源中读取图像,但是由于某种原因,它并没有阅读javascripts。 我已经能够呈现html文档引用这些JavaScript如果HTML文件本身写入到资源,但我想通过设置一个UIWebView的HTML,因此它可以dynamic呈现HTML / JS。 这是我在做什么: NSString * html = @"<!DOCTYPE html><html><head><title>MathJax</title></head><body><script type=\"text/x-mathjax-config\">MathJax.Hub.Config({tex2jax: {inlineMath: [[\"$\",\"$\"],[\"\\(\",\"\\)\"]]}});</script><script type=\"text/javascript\" src=\"/MathJax/MathJax.js\"></script>$$\\int_x^yf(x) dx$$<img src=\"coffee.png\"></body></html>"; NSString * path = [[NSBundle mainBundle] resourcePath]; path = [path stringByReplacingOccurrencesOfString:@"/" withString:@"//"]; path = [path stringByReplacingOccurrencesOfString:@" " withString:@"%20"]; NSString * resourcesPath = [[NSString alloc] initWithFormat:@"file://%@/", path]; [webview loadHTMLString:html baseURL:[NSURL URLWithString:resourcesPath]]; 现在,如果我更改基本url到我的服务器也有所需的文件,它确实加载正确。 不需要互联网连接将是伟大的。 任何帮助表示赞赏! ;) 我发现这对获取图像显示很有用: iPhone […]

window.onbeforeunload不工作在iPad上?

有谁知道,如果在iPad上支持onbeforeunload事件和/或如果有不同的方式来使用它? 我已经尝试了几乎所有的东西,而且似乎从未在iPad(Safari浏览器)上触发onbeforeunload事件。 具体来说,这是我试过的: window.onbeforeunload = function(event) { event.returnValue = 'test'; } window.onbeforeunload = function(event) { return 'test'; } (以上两者一起) window.onbeforeunload = function(event) { alert('test')'; } (所有上面的函数,但在<body onbeforeunload="…"> 所有这些工作在PC上的FF和Safari上,而不是在iPad上。 另外,我刚刚加载页面之后完成了以下操作: alert('onbeforeunload' in window); alert(typeof window.onbeforeunload); alert(window.onbeforeunload); 分别的结果是: true object null 所以,浏览器确实有这个属性,但由于某种原因,它并没有被解雇。 我尝试从页面导航的方法是单击后退和前进button,在顶部栏中进行谷歌search,更改地址栏中的位置,然后单击书签。 有谁知道发生了什么? 我非常感谢任何input。 谢谢