Tag: parsing

将NSString中的选项卡replace为\ t

我正在用SBJsonparsingjson。 我收到错误“-JSONValue失败。错误是:未parsing的控制字符[0x09]”parsing我的JSONstring时,它有未编码的选项卡。 如何将我的jsonstring中的此选项卡replace为\ t? 如果我删除标签manualy,一切都很好。 或者如何正确编码这个标签?

iOS – 在Swift中用NSJSONSerializationparsingJSON字典

我正在使用我的REST Webservice来获取我想要的JSON数据,这个工作原理和打印: [{ "name": "Event1", "genre": "Party", "subtitle": "subtitle1", "startDate": "2015-10-10", "location": "Anywhere" }, { "name": "Event2", "genre": "Party", "subtitle": "subtitle2", "startDate": "2015-10-10", "location": "Anywhere" }] 所以这似乎是一个包含2个元素的字典的数组。 然后我试图用NSJSONSerializationparsingJSON。 let data = str.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false) do { let json = try NSJSONSerialization.JSONObjectWithData(data!, options: []) as! [String: AnyObject] if let name = json["name"] as? [String]{ print(name) } […]

有没有办法将自然语言dateNSString转换为NSDate

假设我有NSString @"tomorrow" 有没有任何库像这样的string,并将其转换成NSDates? 我正在想象/希望这样的事情: NSString* humanDate = @"tomorrow at 4:15"; NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateFormat:@"x at HH:MM"]; NSDate* date = [dateFormatter dateFromString:humanDate]; 我也想做一些像“下一个星期一”等等的东西,但是它不一定非常复杂。 我可以强制input规则,但是我想要一点自然语言。 我的另一种方法是把string分解成几部分,然后手动格式化。 但是我希望有人已经这样做了。

NSXMLParser忽略某些标记之间的文本

我正在尝试parsingxml,但是偶尔如果在使用NSXMLParser下载的标记中存在子/子标记,则之后的任何文本都将被忽略。 这里是一个例子: 在下面的XML块中,我想要文本说: 用胳膊和军人把这个巨大的子宫[NEW LINE]的洞穴填满。 在特洛伊(New Line)看来,泰坦多斯(Tenedos)是一个广为人知的岛屿 XML看起来像: <ln="tr">and fill the caverns of that monstrous womb</l> <ln="tr"> with arms and soldiery. <milestone ed="p" n="21" unit="card"/> In sight of <placeName key="perseus,Troy" authname="perseus,Troy">Troy</placeName> </l> <ln="tr"> lies <placeName key="perseus,Tenedos" authname="perseus,Tenedos">Tenedos</placeName> , an island widely famed </l> 这只发生在标签“里程碑”,即据我所知,“地名”的“l”标签(我下载的那个标签)之间的标签不是问题,“l”和“地名“下载。 这是里程碑的标签。 在上面的例子中,结果看起来像这样: 并填补那巨大的子宫的洞穴。 [新行]特洛伊[新行] Tenedos,一个广为人知的岛屿 正如你所看到的那样,这正是搞乱parsing的“里程碑”标记。 这里是我的代码来设置NSXMLParser: – (void) parser:(NSXMLParser *)parser […]

iOS – 无法从parsing后端stream式传输video

最近,我用mongoLab创build了自己的分析服务器,用于存储我的数据。 我的问题是我保存一个video作为parsingPFFile ,但我似乎无法保存它能够stream。 这是我确切的步骤。 首先,我保存由UIImagePicker返回的video //Get the video URL let videoURL = info[UIImagePickerControllerMediaURL] as? NSURL //Create PFFile with NSData from URL let data = NSData(contentsOfURL: videoURL!) videoFile = PFFile(data: data!, contentType: "video/mp4") //Save PFFile first, then save the PFUser PFUser.currentUser()?.setObject(videoFile!, forKey: "profileVideo") videoFile?.saveInBackgroundWithBlock({ (succeeded, error) -> Void in print("saved video") PFUser.currentUser()?.saveInBackgroundWithBlock({ (succeeded, error) -> Void […]

从parse.com检索图像

我不知道这是否可能,但我认为这是可能的,我不知道如何做到这一点。 我只是想从parse.com加载一个图像,就像从parse.com中检索对象一样。 我应该以同样的方式从parse.com获取string吗? 我刚刚发现如何保存图像的parsing,但没有如何让他们。 我会很高兴,如果有人可以告诉我一个链接来做到这一点或示例代码。 我已经设置了一个从parse中获取的string: PFQuery *query = [PFQuery queryWithClassName:@"app"]; [query getObjectInBackgroundWithId:@"ID" block:^(PFObject *textdu, NSError *error) { if (!error) { UIFont *welcomeLabelFont = [UIFont boldSystemFontOfSize:17]; welcomeLabel.text = [textdu objectForKey:@"ueberschriftnews"]; welcomeLabel.font = welcomeLabelFont; welcomeLabel.textColor = [UIColor whiteColor]; welcomeLabel.textAlignment = NSTextAlignmentCenter; welcomeLabel.backgroundColor = [UIColor clearColor]; welcomeLabel.shadowColor = [UIColor blackColor]; welcomeLabel.shadowOffset = CGSizeMake(0, 1); [contentView addSubview:welcomeLabel]; // […]

parsingJSON(date)到Swift

我在Swift中的应用程序中返回了JSON,并且有一个返回给我的date的字段。 当我提到这个数据时,代码给了我一些像“/ Date(1420420409680)/”。 我如何将其转换成NSDate? 在Swift中,我已经用Objective-Ctesting了一些例子,但没有成功。

SBJsonparsing后执行(__NSArrayM objectForKey :)

我有一些问题试图parsingJSON使用SBJson,我做了一些研究,我找不到有帮助的… 我跟着一些关于如何做的博客,但是我仍然得到这个错误:“__NSArrayM objectForKey:” 所以这是我试图parsing的Json: { "result": [ { "authors": [ "Eric Ries" ], "bc": 9780671607, "title": "Yeah", "urlImage": "www.yeah.hey", "description": "Hey…" } ] } 这是我正在使用的代码: SBJsonParser *json; NSDictionary *jsonResults; NSError *jsonError; json = [ SBJsonParser new ]; // Get result in a NSDictionary jsonResults = (NSDictionary*) [ json objectWithString:output error:&jsonError ]; // Check if there […]

来自NSString的NSUrl返回null

我想parsing从NSString我的文档目录到NSUrl的位置。 当我的控制台NSLog(stringURL) i get: "/var/mobile/Applications/2B35D06D-6E4A-40F2-833E-28463A946834/Library/Application Support/MyAppDirectory" as an output. 但是当我这样做 NSURL* url = [NSURL URLWithString:stringUrl]; 和NSLog(url)我得到(空)作为输出。 我在这里做错了什么?

我的iOS应用程序中的键盘在iPhone 6上太高。如何调整XCode中键盘的分辨率?

目前,我正在将我现有的iOS应用程序调整为iOS 8和iPhone 6.目前,iPhone 6上的键盘看起来相当高(如iPhone 6支持更新之前的WhatsApp应用程序)。 有人可以告诉我,我必须做什么,解决这个在我的代码?